private static CCommand ResolveCommand(Type type) { CCommandAttribute cmdAttr = GetCustomAttribute <CCommandAttribute>(type); if (cmdAttr != null) { string commandName = cmdAttr.Name; if (!IsCorrectPlatform(cmdAttr.Flags)) { Debug.LogWarning("Skipping command: " + commandName); return(null); } CCommand command = CClassUtils.CreateInstance <CCommand>(type); if (command != null) { command.Name = commandName; command.Description = cmdAttr.Description; if (cmdAttr.Values != null) { command.Values = cmdAttr.Values.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } command.Flags |= cmdAttr.Flags; ResolveOptions(command); return(command); } else { CLog.e("Unable to register command: name={0} type={1}", commandName, type); } } return(null); }
private static CPlatformImpl CreateImpl() { try { if (Application.isEditor) { Type type = CClassUtils.TypeForName(EditorPlatformType); if (type != null) { return(CClassUtils.CreateInstance <CPlatformImpl>(type)); } else { Debug.LogError("Can't find " + EditorPlatformType + " type"); } } return(new CPlatformDefault()); } catch (MissingMethodException) // FIXME: I don't like this { // unit test running Type type = CClassUtils.TypeForName("LunarPluginInternal.CTestingPlatform"); return(CClassUtils.CreateInstance <CPlatformImpl>(type)); } }
internal void Init(Object sender, string name, params object[] pairs) { Sender = sender; Name = name; CAssert.IsTrue(pairs.Length % 2 == 0); for (int i = 0; i < pairs.Length;) { string key = CClassUtils.Cast <string>(pairs [i++]); object value = pairs [i++]; this.Set(key, value); } }
public T UserData <T>() where T : class { return(CClassUtils.Cast <T>(userData)); }