internal static void Init() { GsSerializer.OnNewEventHandler += OnNewEventHandler; GsSerializer.OnNewSnapShotReceived += OnNewSnapShotReceived; GsSerializer.CurrentPlayerLeftRoom += CurrentPlayerLeftRoom; GsSerializer.CurrentPlayerJoinRoom += CurrentPlayerJoinRoom; RealTimeEventHandlers.JoinedRoom += JoinedRoom; RealTimeEventHandlers.LeftRoom += LeftRoom; RealTimeEventHandlers.RoomMembersDetailReceived += RoomMembersDetailReceived; _monoBehaviourHandler = new MonoBehaviourHandler(); _prefabHandler = new PrefabHandler(); _functionHandler = new FunctionHandler(); _propertyHandler = new PropertyHandler(); _memberHandler = new MemberHandler(); _monoBehaviourHandler.Init(); _memberHandler.Init(); _propertyHandler.Init(_memberHandler); TypeUtil.Init(); ObjectUtil.Init(); IsAvailable = true; }
internal static void AddAsHandled(SerializedProperty property, IPropertyHandler handler) { if (property.serializedObject.targetObject != null) { _usedHandlers.Add(property.serializedObject.targetObject.GetInstanceID(), new HandlerInfo(property.propertyPath, handler)); } }
private static void ApplyProperty(byte action, byte[] data, string ownerId, IPropertyHandler handler) { var actions = (PropertyAction)action; var property = new PropertyData(); GsSerializer.Object.CallReadStream(property, data); switch (actions) { case PropertyAction.SetOrUpdateMemberProperty: handler.ApplyMemberProperty(ownerId, new Property(property.Name, property.Data)); GsLiveRealtime.Callbacks.OnPropertyEvent?.Invoke(null, new OnPropertyEvent(property.Name, ownerId, actions, property.Data)); break; case PropertyAction.RemoveMemberProperty: handler.RemoveMemberProperty(ownerId, property.Name); GsLiveRealtime.Callbacks.OnPropertyEvent?.Invoke(null, new OnPropertyEvent(property.Name, ownerId, actions)); break; case PropertyAction.SetOrUpdateRoomProperty: handler.ApplyRoomProperty(new Property(property.Name, property.Data)); GsLiveRealtime.Callbacks.OnPropertyEvent?.Invoke(null, new OnPropertyEvent(property.Name, ownerId, actions, property.Data)); break; case PropertyAction.RemoveRoomProperty: handler.RemoveRoomProperty(property.Name); GsLiveRealtime.Callbacks.OnPropertyEvent?.Invoke(null, new OnPropertyEvent(property.Name, ownerId, actions)); break; default: throw new ArgumentOutOfRangeException(); } }
public ContentReferenceListPropertyHandler( IPropertyHandler <ContentReference> contentReferencePropertyHandler, IContentSerializerSettings contentSerializerSettings) { _contentReferencePropertyHandler = contentReferencePropertyHandler ?? throw new ArgumentNullException(nameof(contentReferencePropertyHandler)); _contentSerializerSettings = contentSerializerSettings ?? throw new ArgumentNullException(nameof(contentSerializerSettings)); }
private String GetHandlerDisplayString(IPropertyHandler handler) { return(String.Format( "{0}: {1}", handler.PropertyName, stringFormatter.Format(handler.GetPropertyValue(this)) )); }
//private static bool IsDebug(Dictionary<string, string> config) //{ // return config["DEBUG"] == "true"; //} private static bool LoadDllAndRunDataLoader(Dictionary<string, string> config, IPropertyHandler propertyHandler, IStatusHandler statusHandler) { //UGLY CODE BEGINS string path = ""; if (config["PATH"] == "") { if (Directory.Exists("DataLoaders")) { path = Environment.CurrentDirectory + @"\DataLoaders\" + config["DLL"] + ".dll"; } else { Console.WriteLine("Folder DataLoaders not found, created folder"); Directory.CreateDirectory("DataLoaders"); return false; } } else { path = config["PATH"] + config["DLL"] + ".dll"; } //UGLY CODE ENDS bool oneDataLoader = config["TYPENAME"] != ""; try { Assembly plugin = Assembly.LoadFile(path); Type[] types = plugin.GetTypes(); foreach(var type in types) { //TODO: Find a cleaner and more readeble solution to this if possible //This terrible implementation is trying to do the following: //If the name parameter in config is specified we only want to create an instance of that class and run the DataLoader //if no name is set then we want to execute RunDataLoader for all classes that implement BaseDataLoader if (oneDataLoader) { if (type.Name == config["TYPENAME"]) { RunDataLoader(type, propertyHandler, statusHandler); } } else { RunDataLoader(type, propertyHandler, statusHandler); } } return true; } catch(System.IO.FileNotFoundException ex) { Console.WriteLine("File: " + path + " exception came up: " + ex.Message); return false; } }
/// <summary> /// Creates an instance of <see cref="NullablePropertyHandler{TProperty}" /> that /// unwraps Nullable property values and delegates to an inner /// <see cref="IPropertyHandler" />. /// </summary> /// <param name="innerPropertyHandler"> /// The inner <see cref="IPropertyHandler" /> implementation used to handle /// non-nullable property values. /// </param> /// <param name="property"> /// A <see cref="PropertyInfo" /> on a value object that will potentially /// have its native equality comparison and hash code generation by the /// inheriting class. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="property" /> is null. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="innerPropertyHandler" /> is null. /// </exception> internal NullablePropertyHandler( IPropertyHandler innerPropertyHandler, PropertyInfo property) : base(property) { if (innerPropertyHandler == null) { throw new ArgumentNullException(nameof(innerPropertyHandler)); } this.innerPropertyHandler = innerPropertyHandler; }
//####################### // GetHandler public static IPropertyHandler GetHandler(SerializedProperty property) { if (property == null) { throw new System.ArgumentNullException("property"); } IPropertyHandler result = _handlerCache.GetHandler(property); if (result != null) { return(result); } //TEST FOR SPECIAL CASE HANDLER var fieldInfo = ScriptAttributeUtility.GetFieldInfoFromProperty(property); if (fieldInfo != null && System.Attribute.IsDefined(fieldInfo, typeof(PropertyAttribute))) { var attribs = fieldInfo.GetCustomAttributes(typeof(PropertyAttribute), false) as PropertyAttribute[]; //if (attribs.Length > 1) //{ // if (attribs.Any((a) => a is SPPropertyAttribute)) // { // result = new MultiPropertyAttributePropertyHandler(fieldInfo, attribs); // _handlerCache.SetHandler(property, result); // return result; // } //} //else if (attribs[0] is SPPropertyAttribute) //{ // result = new SPPropertyAttributePropertyHandler(fieldInfo, attribs[0] as SPPropertyAttribute); // _handlerCache.SetHandler(property, result); // return result; //} if (attribs.Any((a) => a is SPPropertyAttribute)) { result = new MultiPropertyAttributePropertyHandler(fieldInfo, attribs); _handlerCache.SetHandler(property, result); return(result); } } //USE STANDARD HANDLER if none was found var handler = StandardPropertyHandler.Instance; _handlerCache.SetHandler(property, handler); return(handler); }
public void SetHandler(SerializedProperty property, IPropertyHandler handler) { if (property == null) throw new System.ArgumentNullException("property"); var hash = GetPropertyHash(property); if(handler == null) { if (_table.ContainsKey(hash)) _table.Remove(hash); } else { _table[hash] = handler; } }
public User(string userId, string userName, string domain, IPropertyCollection properties, IPredefinedNames propertyNames) { if(userId == null) { throw new ArgumentNullException("userId"); } if(string.IsNullOrEmpty(userName)) { throw new ArgumentException("User name can not be empty."); } id = userId; this.domain = (domain ?? string.Empty); this.userName = userName; this.properties = new PropertyHandler(userName, properties, propertyNames); }
public SqliteProperty( PropertyInfo propertyInfo, IPropertyHandler <T> propertyHandler, Func <string, string> namingPolicy) { Info = propertyInfo; Key = propertyInfo.GetCustomAttribute <SqliteKey>(); PropertyHandler = propertyHandler; var column = propertyInfo.GetCustomAttribute <SqliteColumn>(); ColumnName = column is null?namingPolicy.Invoke(Info.Name) : column.Name; var notNull = propertyInfo.GetCustomAttribute <SqliteNotNull>(); var t = Info.PropertyType; CanBeNull = t.IsValueType ? t.IsNullableValueType() : notNull is null; }
public User(string userId, string userName, string domain, IPropertyCollection properties, IPredefinedNames propertyNames) { if (userId == null) { throw new ArgumentNullException("userId"); } if (string.IsNullOrEmpty(userName)) { throw new ArgumentException("User name can not be empty."); } id = userId; this.domain = (domain ?? string.Empty); this.userName = userName; this.properties = new PropertyHandler(userName, properties, propertyNames); }
internal ColumnMapping(string columnName, Type type, IPropertyHandler handler, PropertyInfo property) { Type = type ?? throw new ArgumentNullException(nameof(type)); ColumnName = columnName ?? throw new ArgumentNullException(nameof(columnName)); PropertyHandler = handler ?? throw new ArgumentNullException(nameof(handler)); Property = property; if (Property == null) { return; } if (Property.Name == "Id") { maxLength = DefaultPrimaryKeyIdLength; } else if (Property.Name.EndsWith("Id")) // Foreign keys { maxLength = DefaultMaxForeignKeyIdLength; } }
public void SetHandler(SerializedProperty property, IPropertyHandler handler) { if (property == null) { throw new System.ArgumentNullException("property"); } var hash = GetPropertyHash(property); if (handler == null) { if (_table.ContainsKey(hash)) { _table.Remove(hash); } } else { _table[hash] = handler; } }
public UserService(ICryptographyProvider cryptographyProvider, IPropertyHandler propertyHandler, UserSettings userSettings) { _cryptographyProvider = cryptographyProvider; _propertyHandler = propertyHandler; _userSettings = userSettings; }
public HandlerInfo(string path, IPropertyHandler handler) { this.propPath = path; this.handler = handler; }
public void InitializeHandlers(IPropertyHandler propertyHandler, IStatusHandler statusHandler) { string typeName = this.GetType().Name; _properties = propertyHandler.GetProperties(typeName); _statusHandler = statusHandler; }
internal static void ApplySnapShot(IEnumerable <SnapShotData> data, IPrefabHandler handler = null, IMonoBehaviourHandler monoBehaviourHandler = null, IPropertyHandler propertyHandler = null) { foreach (var shotData in data) { switch (shotData.Type) { case SnapShotType.Function: ApplyFunction(shotData.Buffer, monoBehaviourHandler: monoBehaviourHandler); break; case SnapShotType.Object: ApplyObject((byte)ObjectActions.Instantiate, shotData.Buffer, shotData.OwnerId, handler); break; case SnapShotType.MemberProperty: ApplyProperty((byte)PropertyAction.SetOrUpdateMemberProperty, shotData.Buffer, shotData.OwnerId, propertyHandler); break; case SnapShotType.RoomProperty: ApplyProperty((byte)PropertyAction.SetOrUpdateRoomProperty, shotData.Buffer, shotData.OwnerId, propertyHandler); break; default: throw new GameServiceException("Invalid SnapShot Type!"); } } }
public PropertyTypeController(IPropertyHandler propertyHandler) { _propertyHandler = propertyHandler; }
public PropertyRegistry(IPropertyHandler context) { this.context = context; namedProperties = new SortedDictionary <string, PropertyHolder>(); }
public ContentReferenceListPropertyHandler(IPropertyHandler <ContentReference> contentReferencePropertyHandler) { _contentReferencePropertyHandler = contentReferencePropertyHandler ?? throw new ArgumentNullException(nameof(contentReferencePropertyHandler)); }
public Person(IPropertyHandler propertyHandler) : base(propertyHandler) { }
private static void RunDataLoader(Type type, IPropertyHandler propertyHandler, IStatusHandler statusHandler) { if (type.IsSubclassOf(typeof(BaseDataLoader))) { var loader = (BaseDataLoader)Activator.CreateInstance(type); loader.InitializeHandlers(propertyHandler, statusHandler); loader.RunDataLoader(); } }
IColumnMappingBuilder IColumnMappingBuilder.CustomPropertyHandler(IPropertyHandler propertyHandler) { PropertyHandler = propertyHandler; return(this); }
private static bool SetHandlers(ref IPropertyHandler propertyStore, ref IStatusHandler statusHandler) { string reportStoreType = ""; string reportStoreConnectionString = ""; string porpertyStoreType = ""; string propertyStoreConnectionString = ""; try { IniParser ini = new IniParser("conf.ini"); reportStoreType = ini.GetSetting("STATUS_REPORT", "REPORT_TO"); reportStoreConnectionString = ini.GetSetting("STATUS_REPORT", "REPORT_CONNECTION"); porpertyStoreType = ini.GetSetting("PROPERTY_STORE", "TYPE"); propertyStoreConnectionString = ini.GetSetting("PROPERTY_STORE", "CONNECTION"); } catch (System.IO.FileNotFoundException ex) { Console.WriteLine(ex.Message); return false; } //Setup property store //Currently we hardcode this to SQL Server, the infrastructure to reflect on it is in place propertyStore = new Aih.DataLoader.Tools.PropertyHandlers.SQLServerPropertyHandler(propertyStoreConnectionString); //Setup where to report status to //Currently we hardcode this to SQL Server, the infrastructure to reflect on it is in place statusHandler = new Aih.DataLoader.Tools.StatusHandlers.SQLServerStatusHandler(reportStoreConnectionString); return true; }
internal static void ApplyData(Types types, string ownerId, byte[] subCaller, byte[] extra, IPrefabHandler handler = null, IMonoBehaviourHandler monoBehaviourHandler = null, IPropertyHandler propertyHandler = null) { switch (types) { case Types.ObserverActions: ApplyTransform(subCaller[1], ownerId, extra); break; case Types.ObjectsActions: ApplyObject(subCaller[1], extra, ownerId, handler); break; case Types.RunFunction: ApplyFunction(extra, monoBehaviourHandler: monoBehaviourHandler); break; case Types.Property: ApplyProperty(subCaller[1], extra, ownerId, propertyHandler); break; default: throw new ArgumentOutOfRangeException(nameof(types), types, null); } }
protected PropertyHandlerDecorator(IPropertyHandler original) { this.original = original; }
static void Indexer() { string indexerFile = ""; try { Guid IPropertyStoreGuid = new Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"); DirectoryInfo di = new DirectoryInfo(targetDirectory); bool done = false; while (!done) { foreach (FileInfo file in di.GetFiles()) { indexerFile = file.Name; // To simulate indexer, open handler directly to get fine-grained control over flags //HResult hr = (HResult)SHGetPropertyStoreFromParsingName(file.FullName, IntPtr.Zero, // GETPROPERTYSTOREFLAGS.GPS_DEFAULT, ref IPropertySto on '{indexerFile}'reGuid, out IPropertyStore ps); var ps = new IPropertyHandler(); try { HResult hr = ps.Initialize(file.FullName, (uint)(StgmConstants.STGM_READ | StgmConstants.STGM_SHARE_DENY_NONE)); if (hr == HResult.Ok) { hr = ps.GetCount(out uint propertyCount); if (hr == HResult.Ok) { for (uint index = 0; index < propertyCount; index++) { PropVariant val = new PropVariant(); hr = ps.GetAt(index, out PropertyKey key); if (hr == HResult.Ok) { hr = ps.GetValue(key, val); if (hr == HResult.Ok) { LogLine(3, $"Indexer read {val}"); } else { throw new Exception($"GetValue failed with 0x{hr:X}"); } } else { throw new Exception($"GetAt failed with 0x{hr:X}"); } } } else if ((uint)hr == 0x80030021) { LogLine(2, $"GetCount for {indexerFile} failed with STG_E_LOCKVIOLATION"); IncrementIndexerFail(); } else { throw new Exception($"GetCount failed with 0x{hr:X}"); } done = IncrementIndexer(); if (done) { break; } } else if ((uint)hr == 0x80030021) { LogLine(2, $"Open for {indexerFile} failed with STG_E_LOCKVIOLATION"); IncrementIndexerFail(); } //else // throw new Exception($"Open failed with 0x{hr:X}"); else { // Indexer can tolerate some failures, but not too many LogLine(1, $"Indexer Open failed on '{indexerFile}' with 0x{hr:X}"); IncrementIndexerFail(); } } finally { Marshal.ReleaseComObject(ps); // optional GC preempt } } } } catch (Exception ex) { LogLine(1, $"Indexer terminated on '{indexerFile}': {ex}"); IncrementIndexerTerminated(); } }