I have a shape named Account_UserDetails, that I'm trying to add some sort of wrapper to because it's just displaying as a bunch of LI's. I need a wrapper around the shape to control it better (like a UL). I tried the following but it doesnt seem to be showing in the browser at all. What am I doing wrong?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.DisplayManagement.Descriptors;
namespace Onestop.Themes.LOEH
{
public class ShapeDataProvider : IShapeTableProvider
{
public void Discover(ShapeTableBuilder builder)
{
builder.Describe("Account_UserDetails").OnDisplaying(context => {
context.Shape.Wrappers.Add("ul");
});
}
}
}
Wrappers in Orchard are shapes, you can add them as following:
builder.Describe("Account_UserDetails").OnDisplaying(context => {
context.Shape.Metadata.Wrappers.Add("Account_UserDetails_Wrapper");
});
Then you should add the wrapper shape as Account_UserDetails_Wrapper.cshtml:
<div>
#DisplayChildren(Model)
</div>
if you need more info about wrappers, please refer to this link
Related
I was trying to create a Template that takes in a Type to substitute it's name in a template.
The template looks like this
using System;
using System.Collections.Generic;
using System.Text;
namespace $rootnamespace$
{
public class $safeitemrootname$<$TView$>
{
}
}
I substitute the $TView$ parameter with the selected Type in my custom IWizard.
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
DTE dte = (DTE)automationObject;
Project project = dte.SelectedItems.Item(1) as Project;
VSProject vsProj = (VSProject)project.Object;
foreach (Reference reference in vsProj.References)
{
if (reference.SourceProject == null)
{
// Assembly reference
}
else
{
// Project reference
}
}
}
The real problem comes in here: how can I show a grid with all the Types in all of the referenced assemblies of a project?
I tried to do load the Assembly with Assembly.Load, Assembly.LoadFrom, Assembly.ReflectionOnlyLoad, Assembly.ReflectionOnlyLoadFrom and many others (also with AppDomain), but I alwais get an error asking to load the dependencies first.
Is there any way to get the defined types in all assemblies of a project with envDTE or Reflection?
I am pretty new to Unity and game development so sorry if this is a stupid mistake.
I am trying to create a UI in which you enter text into a input field (TMP), the script will check the input and if it reads "password", a Debug.Log is shown in the console.
I have looked around online for any help with this but nothing seems to work.
I have got a script that I assume to work, but I am getting one major problem: On line 15 it cant find the Input Field that I am trying to reference?
The script is attached to the Input Field, I am trying to reference it from there.
Any help would be greatly appreciated... Thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CheckPassword : MonoBehaviour
{
public InputField inputField;
public void Awake()
{
inputField = GetComponent<InputField>();
}
public void CheckInputField()
{
if (inputField.text == "password")
{
Debug.Log("Password Correct");
}
}
}
The problem was that due to the fact that I was using a Text Mesh Pro Input Field I had to specify that in the variable.
Instead I used: [SerializeField] TMPro.TMP_InputField inputField;
And the awake function was not necessary either.
I would like to create a base class for observableObject generic enough for an observable object to derive from, but I hit some technical issue. This is an extract of the class. It is an abstract that implements interface INotifyPropertyChanged. But when I tried to use PropertySupport.ExtractPropertyName, I got compiler error saying 'PropertySupport' not exist in the current context. I am using VS2002. My intention was to create a library to host a small "framework" of my own and use it for different projects. Could anyone more well versed in the reflection point out what was wrong in my code to cause the compiler error?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace MyFramework
{
[Serializable]
public abstract class ObservableObject: INotifyPropertyChanged
{
[field: NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
{
var handler = this.PropertyChanged;
if (handler!=null)
{
handler(this, e);
}
}
protected void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpression)
{
var propertyName = PropertySupport.ExtractPropertyName(propertyExpression);
this.RaisePropertyChanged(propertyName);
}
protected void RaisePropertyChanged(String propertyName)
{
OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
}
}
The error you are getting usually refers to a missing using directive or missing reference.
Looking at MSDN for the function you are trying to use it looks like you are missing the using directive Prism.ViewModel
using Microsoft.Practices.Prism.ViewModel;
If this doesn't fix your problem then you need to add a reference to the correct dll
Microsoft.Practices.Prism.Composition.dll
I've never used Prism but after copying your class, adding the correct reference & using directive it built ok.
In monotouch using c# I have used [Register("CpyRightCusTabVwCell")] above the afore mentioned class. Now I want to un-register that class. How do I do that in monotouch using C#?
using System;
using MonoTouch;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Runtime.CompilerServices;
using System.Net.Mime;
using NUnitLite.Runner;
namespace egUniSBPersHlthCareManager
{
[Register("CpyRightCusTabVwCell")]
public partial class CpyRightCusTabVwCell : UITableViewCell
{
public CpyRightCusTabVwCell(IntPtr handel):base (handel)
{
}
public CpyRightCusTabVwCell ()
{
}
}
}
You can't.
Class registration is for life (of the process).
Note: All sample code is greatly simplified.
I have a DLL defined as:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;
namespace RIV.Module
{
public interface IModule
{
StringWriter ProcessRequest(HttpContext context);
string Decrypt(string interactive);
string ExecutePlayerAction(object ParamObjectFromFlash);
void LogEvent(object LoggingObjectFromFlash);
}
}
Now, outside of my solution, other developers can define concrete classes and drop them into the BIN folder of my app. Maybe something like:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RIV.Module;
namespace RIV.Module.Greeting
{
public class Module : IModule
{
public System.IO.StringWriter ProcessRequest(System.Web.HttpContext context)
{
//...
}
public string Decrypt(string interactive)
{
//...
}
public string ExecutePlayerAction(object ParamObjectFromFlash)
{
//...
}
public void LogEvent(object LoggingObjectFromFlash)
{
//...
}
}
}
Now, in my app I would need to know that a new Module was available (I am guessing via web.config or something along those lines) and then be able to call it based off of some trigger in the database Campaign table (which maps to the module to use for that specific campaign).
I am trying to instantiate it this way:
var type = typeof(RIV.Module.Greeting.Module);
var obj = (RIV.Module.Greeting.Module)Activator.CreateInstance(type);
However, the compiler belches because a reference was never set to RIV.Module.Greeting.dll!
What am I doing wrong?
You need to use more reflection:
Load the assembly by calling Assembly.Load
Find the type by calling someAssembly.GetType(name) or searching someAssembly.GetTypes()
Pass the Type instance to Activator.CreateInstance
Cast it to your interface.
Instead of typeof(RIV.Module.Greeting.Module), try using
var type = Type.GetType("RIV.Module.Greeting.Module, RIV.Module.Greeting");
(i.e. load the type by specifying its assembly-qualified name as string) and casting to IModule.
This approach requires you to know the exact class and assembly names of the modules (as you wrote, they could be stored in web.config).
Alternatively, you could go for a completely dynamic plugin approach:
establish a convention that all module assemblies should be named "RIV.Module.XYZ"
scan the bin directory for matching DLLs
for each DLL, load it (e.g. Assembly.Load) and scan for types implementing IModule
instantiate all found types and cast to IModule