public MethodMapper(ITypeMap typeMap) { Func <MethodInfo, bool> methodPredicate = (methodInfo) => { return(!methodInfo.IsSpecialName); }; var mapped = typeMap.Select(map => new { ContractType = map.ContractType, ImplementationType = map.ImplementationType, ContractMethods = map.ContractType.GetMethods().Where(methodPredicate), ImplMethods = map.ImplementationType.GetMethods().ToSet(methodPredicate), }); var mappedMethodsEnumerable = mapped.SelectMany(map => { var methods = map.ContractMethods; return(methods.Select(method => { var match = method.SelectFirst(map.ImplMethods, (c, impl) => c.IsMatchedTo(impl), (c, impl) => new { ImplMethod = impl, ContractMethod = c }); return new MethodMap(map.ContractType, map.ImplementationType, match.ImplMethod, match.ContractMethod); })); }); mappedMethods = mappedMethodsEnumerable.Cast <IMethodMap>() .ToList(); }
protected override void AwakeOverride() { base.AwakeOverride(); if (!TreeViewPrefab) { Debug.LogError("Set TreeViewPrefab field"); return; } m_treeView = Instantiate(TreeViewPrefab).GetComponent <VirtualizingTreeView>(); m_treeView.transform.SetParent(transform, false); //m_treeView.RemoveKey = KeyCode.None; m_treeView.ItemDataBinding += OnItemDataBinding; m_treeView.SelectionChanged += OnSelectionChanged; m_treeView.ItemsRemoved += OnItemsRemoved; m_treeView.ItemExpanding += OnItemExpanding; m_treeView.ItemBeginDrag += OnItemBeginDrag; m_treeView.ItemBeginDrop += OnItemBeginDrop; m_treeView.ItemDrop += OnItemDrop; m_treeView.ItemEndDrag += OnItemEndDrag; m_treeView.ItemDoubleClick += OnItemDoubleClicked; m_treeView.ItemBeginEdit += OnItemBeginEdit; m_treeView.ItemEndEdit += OnItemEndEdit; m_project = RTSL2Deps.Get.Project; m_typeMap = RTSL2Deps.Get.TypeMap; }
public ProjectAsyncOperation SetValue <T>(string key, T obj, ProjectEventHandler callback = null) { ProjectAsyncOperation ao = new ProjectAsyncOperation(); ITypeMap typeMap = IOC.Resolve <ITypeMap>(); Type persistentType = typeMap.ToPersistentType(typeof(T)); if (persistentType == null) { ao.Error = new Error(Error.E_NotFound); if (callback != null) { callback(ao.Error); } ao.IsCompleted = true; } else { PersistentSurrogate surrogate = (PersistentSurrogate)Activator.CreateInstance(persistentType); surrogate.ReadFrom(obj); ISerializer serializer = IOC.Resolve <ISerializer>(); byte[] bytes = serializer.Serialize(surrogate); string data = Convert.ToBase64String(bytes); PlayerPrefs.SetString(key, data); ao.Error = Error.NoError; if (callback != null) { callback(ao.Error); } ao.IsCompleted = true; } return(ao); }
/// <summary> /// Initializes a new instance of the <see cref="PostgresColumn"/> class. /// </summary> /// <param name="quoter">The Postgres quoter.</param> /// <param name="typeMap">The Postgres type map.</param> public PostgresColumn([NotNull] PostgresQuoter quoter, ITypeMap typeMap) : base(typeMap, quoter) { AlterClauseOrder = new List <Func <ColumnDefinition, string> > { FormatAlterType, FormatAlterNullable }; }
public UnityObjectFactory() { m_standardShader = Shader.Find("Standard"); Debug.Assert(m_standardShader != null, "Standard shader is not found"); m_typeMap = IOC.Resolve <ITypeMap>(); }
private static string SerializeValue(ITypeMap typeMap, object value, StringSerializationMode mode = StringSerializationMode.HtmlEncoded) { var stream = new StringBuilder(); var protocol = new XRoadProtocol("2.0", new CustomSchemaExporterXRoad20(mode)); using (var textWriter = new StringWriter(stream)) using (var writer = XmlWriter.Create(textWriter)) using (var message = protocol.CreateMessage()) { writer.WriteStartDocument(); writer.WriteStartElement("value"); typeMap.Serialize(writer, null, value, Globals.GetTestDefinition(typeMap.Definition.Type), message); writer.WriteEndElement(); writer.WriteEndDocument(); } using (var textReader = new StringReader(stream.ToString())) using (var reader = XmlReader.Create(textReader)) { while (reader.Read() && reader.LocalName != "value") { } return(reader.ReadInnerXml()); } }
private static void SaveDependencies(GetDepsFromContext context, ITypeMap typeMap, IAssetDB assetDB, string path) { object[] dependencies = context.Dependencies.ToArray(); foreach (UnityObject dep in dependencies) { Type persistentType = typeMap.ToPersistentType(dep.GetType()); if (persistentType != null) { context.Dependencies.Clear(); IPersistentSurrogate persistentObject = (IPersistentSurrogate)Activator.CreateInstance(persistentType); persistentObject.GetDepsFrom(dep, context); SaveDependencies(context, typeMap, assetDB, path); } } foreach (UnityObject dep in dependencies) { if (dep is Component || dep is GameObject || !assetDB.IsDynamicResourceID(assetDB.ToID(dep))) { continue; } string name = dep.name; if (string.IsNullOrWhiteSpace(name)) { name = dep.GetType().Name; } string uniqueAssetPath = AssetDatabase.GenerateUniqueAssetPath(string.Format("{0}/{1}.asset", path, name)); AssetDatabase.CreateAsset(dep, uniqueAssetPath); } }
public PropertyMapper(ITypeMap mixinsMap) { var mapped = mixinsMap.Select(mixin => new { ContractType = mixin.ContractType, ImplementationType = mixin.ImplementationType, ContractProperties = mixin.ContractType.GetProperties(), ImplProperties = mixin.ImplementationType.GetProperties().ToSet() }); var mappedPropertiesEnumerable = mapped.SelectMany(map => { var properties = map.ContractProperties; return(properties.Select(property => { var match = property.SelectFirst(map.ImplProperties, (c, impl) => c.IsMatchedTo(impl), (c, impl) => new { ImplProperty = impl, ContractProperty = c }); return new PropertyMap(map.ContractType, map.ImplementationType, match.ImplProperty, match.ContractProperty); })); }); mappedProperties = mappedPropertiesEnumerable.Cast <IPropertyMap>() .ToList(); }
public static void Change(object sender, ITypeMap newinst) { ITypeMap old = Instance; if (old == newinst) { throw new ArgumentException(); } Instance = newinst ?? throw new ArgumentNullException(nameof(newinst)); TypeMapChangedArgs args = new TypeMapChangedArgs(old, newinst); OnChanged.Invoke(sender, args); if (args.AutoDisposing) { if (old is IDisposable v1) { v1.Dispose(); } else if (old is IRuntimeTypeMapEX v2) { v2.Dispose(); } } }
protected override void AwakeOverride() { base.AwakeOverride(); m_typeMap = RTSL2Deps.Get.TypeMap; m_assetDB = RTSL2Deps.Get.AssetDB; m_project = RTSL2Deps.Get.Project; if (!ListBoxPrefab) { Debug.LogError("Set ListBoxPrefab field"); return; } m_listBox = GetComponentInChildren <VirtualizingTreeView>(); if (m_listBox == null) { m_listBox = Instantiate(ListBoxPrefab).GetComponent <VirtualizingTreeView>(); m_listBox.CanDrag = true; m_listBox.CanReorder = false; //m_listBox.MultiselectKey = KeyCode.None; // m_listBox.RangeselectKey = KeyCode.None; //m_listBox.RemoveKey = KeyCode.None; m_listBox.transform.SetParent(transform, false); } m_listBox.ItemDataBinding += OnItemDataBinding; }
public void AddInput <TInput>( Expression <Func <IObservable <TInput> > > createInput, params Type[] typeMaps) { var mapInstances = new ITypeMap <TInput> [typeMaps.Length]; for (int i = 0; i < typeMaps.Length; i++) { object o = Activator.CreateInstance(typeMaps[i]); if (o == null) { throw new Exception("Activator.CreateInstance failed for type " + typeMaps[i].Name); } ITypeMap <TInput> mapInstance = o as ITypeMap <TInput>; if (mapInstance == null) { throw new Exception("The type " + typeMaps[i].FullName + " must implement one of these interfaces :" + typeof(ITypeMap <>).Name + ", " + typeof(IRootTypeMap <,>).Name + ", " + typeof(IPartitionableTypeMap <,>).Name); } mapInstances[i] = mapInstance; } AddInput(createInput, mapInstances); }
protected PostgresGenerator( [NotNull] PostgresQuoter quoter, [NotNull] IOptions <GeneratorOptions> generatorOptions, ITypeMap typeMap) : base(new PostgresColumn(quoter, typeMap), quoter, new PostgresDescriptionGenerator(quoter), generatorOptions) { }
public AbstractModelColumnsBuilder(ISQLTranslator tr, ITypeMap tm) { tr.ThrowIfNullArgument(nameof(tr)); tm.ThrowIfNullArgument(nameof(tm)); this._tr = tr; this._tm = tm; }
public Scanner(IExceptionHandler handler, ITypeMap typeMap) { this.handler = handler ?? ExceptionHandlerFactory.Default; this.typeMap = typeMap ?? TypeTable.Instance; ck_table = LoadDefaultCharKeywordTable(); sym_table = LoadDefaultSymbolTable(); }
public ColumnBase(ITypeMap typeMap, IQuoter quoter) { _typeMap = typeMap; _quoter = quoter; ClauseOrder = new List <Func <ColumnDefinition, string> > { FormatString, FormatType, FormatNullable, FormatDefaultValue, FormatPrimaryKey, FormatIdentity }; }
public HandlerInvoker(IMessageSource messageSource, IServiceCollection registeredServices, ITypeMap typeMap, string endpointName, IOutgoingPipeline outgoingPipeline) { this.messageSource = messageSource; this.registeredServices = registeredServices; this.typeMap = typeMap; this.endpointName = endpointName; this.outgoingPipeline = outgoingPipeline; }
internal MixinsTypeDefinition(Type mixinsType, ITypeMap mixinsMap) { Type = mixinsType; this.mixinsMap = mixinsMap; mixinTypeDefinitions = new Dictionary <Type, MixinTypeDefinition>(); CreateTypeBuilder(); CreateMixinTypeDefinitions(); CreateDefaultConstructor(); }
public void RegisterMapping(ITypeMap <TContext> map) { AssertIsNotInitialized(); _defaultMaps.Add(map); if (_diagnosticsEnabled) { _mapCreationInfo.Add(new MapInfoEntry(map)); } }
protected virtual void AwakeOverride() { m_shaderUtil = ShaderUtil; m_assetDB = AssetDB; m_typeMap = TypeMap; m_objectFactory = ObjectFactory; m_serializer = Serializer; m_storage = Storage; m_project = Project; }
private void Awake() { m_editor = IOC.Resolve <IRTE>(); m_localization = IOC.Resolve <ILocalization>(); m_project = IOC.Resolve <IProject>(); m_project.DeleteCompleted += OnDeleteProjectItemCompleted; m_editorsMap = IOC.Resolve <IEditorsMap>(); m_typeMap = IOC.Resolve <ITypeMap>(); IOC.RegisterFallback <IRuntimeScriptManager>(this); }
protected AbstractModelSQLEmit(IObjectMapInfoCache cache, ISQLTranslator tr, ITypeMap tm, IModelColumnsBuilder cb) { tr.ThrowIfNullArgument(nameof(tr)); tm.ThrowIfNullArgument(nameof(tm)); cb.ThrowIfNullArgument(nameof(cb)); cache.ThrowIfNullArgument(nameof(cache)); this._tr = tr; this._tm = tm; this._cb = cb; this._cache = cache; }
static ObjectFactory() { ObjectFactory singleton = new ObjectFactory(); // 注册抽象类型需要使用的实体类型 // 该类型实体具有构造参数,实际的配置信息可以从外层机制获得。 singleton.dictionary.Add(typeof(IUserService), new TypeConstructor(typeof(UserService))); singleton.dictionary.Add(typeof(IResourceService), new TypeConstructor(typeof(ResourceService))); //新接口注入在下面增加 Instance = singleton; }
private void Awake() { m_storage = IOC.Resolve <IStorage>(); m_assetDB = IOC.Resolve <IAssetDB>(); m_typeMap = IOC.Resolve <ITypeMap>(); m_factory = IOC.Resolve <IUnityObjectFactory>(); if (m_dynamicPrefabsRoot == null) { m_dynamicPrefabsRoot = transform; } }
private void Awake() { m_storage = RTSL2Deps.Get.Storage; m_assetDB = RTSL2Deps.Get.AssetDB; m_typeMap = RTSL2Deps.Get.TypeMap; m_factory = RTSL2Deps.Get.UnityObjFactory; if (m_dynamicPrefabsRoot == null) { m_dynamicPrefabsRoot = transform; } }
private void SerializeValue(XmlWriter writer, object value, ITypeMap typeMap, IXmlTemplateNode templateNode, XRoadMessage message, ContentDefinition content) { if (value == null) { writer.WriteNilAttribute(); return; } var concreteTypeMap = typeMap.Definition.IsInheritable ? serializer.GetTypeMap(value.GetType()) : typeMap; concreteTypeMap.Serialize(writer, templateNode, value, content, message); }
private void OnProjectFolderValidateContextMenuOpenCommand(object sender, ProjectTreeCancelEventArgs e) { if (e.ProjectItem is AssetItem) { AssetItem assetItem = (AssetItem)e.ProjectItem; ITypeMap typeMap = IOC.Resolve <ITypeMap>(); if (typeMap.ToType(assetItem.TypeGuid) == typeof(RuntimeTextAsset) && e.ProjectItem.Ext == Ext) { e.Cancel = false; } } }
protected virtual void OnDestroy() { if (this == (MonoBehaviour)Get) { Get = null; m_assetDB = null; m_typeMap = null; m_unityObjFactory = null; m_serializer = null; m_storage = null; m_project = null; } }
#pragma warning disable IDE0004 public static ITypeMap New(bool isThreadSafe, bool initDefault) { ITypeMap result = isThreadSafe ? (ITypeMap) new SafeRuntimeTypeMap() : (ITypeMap) new ConcurrentTypeMap(); if (initDefault) { InitDefault(result); } return(result); }
protected virtual void Dispose(bool disposing) { if (handler != null) { handler = null; typeMap = null; sym_table.Dispose(); sym_table = null; ck_table.Dispose(); ck_table = null; } }
public void Create(ITypeMap typeMap) { typeMap.Register(typeof(RuntimePrefab), typeof(PersistentRuntimePrefab <>), new Guid("430451d7-d09d-45e0-8fac-3d061e10f654"), new Guid("6c20bf67-8156-4e43-99f9-025d03e7d0a5")); typeMap.Register(typeof(GameObject), typeof(PersistentGameObject <>), new Guid("2e76e2f0-289d-4c48-936f-56033397359c"), new Guid("163584cb-bfc6-423c-ab02-e43c961af6d6")); typeMap.Register(typeof(Transform), typeof(PersistentTransform <>), new Guid("b542d079-2da8-4468-80b4-ba4c6adaa225"), new Guid("3b5d0310-44df-44a1-8689-245048c8151a")); typeMap.Register(typeof(UnityObject), typeof(PersistentObject <>), new Guid("9cdd70ef-9948-4b85-8432-09eaf0faf4b7"), new Guid("b4abccaa-7fd8-4035-8c90-2d46ac7278ed")); typeMap.Register(typeof(Component), typeof(PersistentComponent <>), new Guid("d19c5e1f-80d6-4294-9be4-713150ba5152"), new Guid("f7be1b4c-1306-4074-8076-f8bef011ab72")); typeMap.Register(typeof(UnityEvent), typeof(PersistentUnityEvent <>), new Guid("3ed54cee-4405-475c-8954-a5eaed086ad7"), new Guid("9f432f32-23f3-432c-992d-6cc43b8edbad")); typeMap.Register(typeof(UnityEventBase), typeof(PersistentUnityEventBase <>), new Guid("9e9f6774-aeb8-4cc5-b149-597a62077a89"), new Guid("1f0e42fc-2817-49d9-af67-1fd15dd6f9ed")); typeMap.Register(typeof(Color), typeof(PersistentColor <>), new Guid("c5aaef8c-fce2-4ce9-8474-7094e24e7ea6"), new Guid("baea5d8e-ae9a-4eb7-bbf4-e6e80e0c85d3")); typeMap.Register(typeof(Vector3), typeof(PersistentVector3 <>), new Guid("28d91efe-0de0-478d-9e7b-c76f1ba91807"), new Guid("d1b8fcf4-3b8a-48f1-836f-86666243ece8")); typeMap.Register(typeof(Vector4), typeof(PersistentVector4 <>), new Guid("210fd541-e678-45dc-bb96-69333099ddf4"), new Guid("dce295a4-7b33-408c-b87e-6b85a3358dbf")); typeMap.Register(typeof(Quaternion), typeof(PersistentQuaternion <>), new Guid("a2c70442-63fd-4b71-a7ff-ce1749c513f3"), new Guid("7e0cfd74-0fa9-4160-bdba-2498f6069b4b")); }
public SqlServerColumn(ITypeMap typeMap) : base(typeMap, new SqlServerQuoter()) { }
public SqlServerColumn(ITypeMap typeMap) : base(typeMap, new ConstantFormatter()) { }
public ColumnBase(ITypeMap typeMap, IQuoter quoter) { _typeMap = typeMap; _quoter = quoter; ClauseOrder = new List<Func<ColumnDefinition, string>> { FormatString, FormatType, FormatNullable, FormatDefaultValue, FormatPrimaryKey, FormatIdentity }; }
public ColumnBase(ITypeMap typeMap, IConstantFormatter constantFormatter) { _typeMap = typeMap; _constantFormatter = constantFormatter; ClauseOrder = new List<Func<ColumnDefinition, string>> { FormatName, FormatType, FormatNullable, FormatDefaultValue, FormatIdentity, FormatPrimaryKey }; }
public ModelColumnsBuilder(ISQLTranslator tr, ITypeMap tm) : base(tr, tm) { }
public AbstractDatabaseMeta(ITypeMap map) { _map = map; _tables = new List<ITable>(); _dict = new Dictionary<string, List<IColumn>>(); }
public SqlServerCeColumn(ITypeMap typeMap) : base(typeMap) { }
public DatabaseMeta(ITypeMap map) : base(map) { }