internal LayeredArchitectureImpl(IEnumerable <CompositeModelTypeAssemblyScopeSupport> modelTypeSupport) : base(modelTypeSupport) { this._allLayers = this.CollectionsFactory.NewDictionaryProxy <String, LayerArchitectureImpl>(); this._usageInfos = this.CollectionsFactory.NewDictionaryProxy <LayerArchitectureImpl, ListProxy <LayerArchitectureImpl> >(); this._compositeIDGenerator = new CompositeIDGenerator().IDGeneratorFunction; }
internal LayeredApplicationImpl( LayeredApplicationModel model, IEnumerable <Tuple <CompositeModelType, CompositeModelTypeModelScopeSupport> > compositeModelTypeSupport, ApplicationValidationResultIQ validationResult, DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults, String name, String mode, String version ) : base( model, compositeModelTypeSupport, name, mode, version ) { DictionaryProxy <LayerModel, LayerImpl> allLayers = model.CollectionsFactory.NewDictionaryProxy <LayerModel, LayerImpl>(); foreach (LayerModel layerModel in model.TopLevelLayers) { this.ProcessLayers(validationResult, loadingResults, allLayers, layerModel); } this._allLayers = allLayers.CQ; }
public static void Serialize(Stream stream, AccountCompletionResultView instance) { int mask = 0; using (var bytes = new MemoryStream()) { if (instance.ItemsAttributed != null) { DictionaryProxy <int, int> .Serialize(bytes, instance.ItemsAttributed, Int32Proxy.Serialize, Int32Proxy.Serialize); } else { mask |= 1; } if (instance.NonDuplicateNames != null) { ListProxy <string> .Serialize(bytes, instance.NonDuplicateNames, StringProxy.Serialize); } else { mask |= 2; } Int32Proxy.Serialize(bytes, instance.Result); Int32Proxy.Serialize(stream, ~mask); bytes.WriteTo(stream); } }
private static void Main() { try { var settings = ReadSettings(); ActorRuntime.RegisterActorAsync <MatchingEngine>( (context, actorType) => new ActorService(context, actorType, () => { var assetPairQuoteRepository = new AssetPairQuoteRepository(); var dictionaryProxy = new DictionaryProxy(settings.Factories); return(new MatchingEngine(dictionaryProxy, new AccountInfoRepository(), assetPairQuoteRepository, new MarketOrderRepository(), new PendingOrderRepository(), new TransactionHistoryRepository(), new OrderCalculator(assetPairQuoteRepository, dictionaryProxy), new MatchingEngineEventSubscriber(settings.MatchingEngine), new OrderBookService(assetPairQuoteRepository, dictionaryProxy))); })) .GetAwaiter() .GetResult(); MappingConfig.Configure(); Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ActorEventSource.Current.ActorHostInitializationFailed(e.ToString()); throw; } }
public static MapView Deserialize(Stream bytes) { var mask = Int32Proxy.Deserialize(bytes); var view = new MapView(); if ((mask & 1) != 0) { view.Description = StringProxy.Deserialize(bytes); } if ((mask & 2) != 0) { view.DisplayName = StringProxy.Deserialize(bytes); } view.IsBlueBox = BooleanProxy.Deserialize(bytes); view.MapId = Int32Proxy.Deserialize(bytes); view.MaxPlayers = Int32Proxy.Deserialize(bytes); view.RecommendedItemId = Int32Proxy.Deserialize(bytes); if ((mask & 4) != 0) { view.SceneName = StringProxy.Deserialize(bytes); } if ((mask & 8) != 0) { view.Settings = DictionaryProxy <GameModeType, MapSettingsView> .Deserialize(bytes, EnumProxy <GameModeType> .Deserialize, MapSettingsViewProxy.Deserialize); } view.SupportedGameModes = Int32Proxy.Deserialize(bytes); view.SupportedItemClass = Int32Proxy.Deserialize(bytes); return(view); }
public static ApplicationConfigurationView Deserialize(Stream bytes) { int mask = Int32Proxy.Deserialize(bytes); var view = new ApplicationConfigurationView(); view.MaxLevel = Int32Proxy.Deserialize(bytes); view.MaxXp = Int32Proxy.Deserialize(bytes); view.PointsBaseLoser = Int32Proxy.Deserialize(bytes); view.PointsBaseWinner = Int32Proxy.Deserialize(bytes); view.PointsHeadshot = Int32Proxy.Deserialize(bytes); view.PointsKill = Int32Proxy.Deserialize(bytes); view.PointsNutshot = Int32Proxy.Deserialize(bytes); view.PointsPerMinuteLoser = Int32Proxy.Deserialize(bytes); view.PointsPerMinuteWinner = Int32Proxy.Deserialize(bytes); view.PointsSmackdown = Int32Proxy.Deserialize(bytes); view.XpBaseLoser = Int32Proxy.Deserialize(bytes); view.XpBaseWinner = Int32Proxy.Deserialize(bytes); view.XpHeadshot = Int32Proxy.Deserialize(bytes); view.XpKill = Int32Proxy.Deserialize(bytes); view.XpNutshot = Int32Proxy.Deserialize(bytes); view.XpPerMinuteLoser = Int32Proxy.Deserialize(bytes); view.XpPerMinuteWinner = Int32Proxy.Deserialize(bytes); if ((mask & 1) != 0) { view.XpRequiredPerLevel = DictionaryProxy <int, int> .Deserialize(bytes, Int32Proxy.Deserialize, Int32Proxy.Deserialize); } view.XpSmackdown = Int32Proxy.Deserialize(bytes); return(view); }
protected ApplicationArchitectureSkeleton(IEnumerable <CompositeModelTypeAssemblyScopeSupport> modelTypeSupport) { ArgumentValidator.ValidateNotNull("Composite model type supports", modelTypeSupport); this._collectionsFactory = CollectionsFactorySingleton.DEFAULT_COLLECTIONS_FACTORY; this._modelTypeSupport = this._collectionsFactory.NewDictionaryProxy(modelTypeSupport.ToDictionary(support => support.ModelType, support => support)).CQ; this._metaInfoContainer = UsesContainerMutableImpl.CreateEmpty(); this._additionalInjectionFunctionalities = this._collectionsFactory.NewDictionaryProxy <Type, InjectionFunctionality>(); }
public Project() { CodeWeighting = new DictionaryProxy<FileTypes, float>(new Dictionary<FileTypes, float>()); Sloc = new DictionaryProxy<FileTypes, List<LocReport>>(new Dictionary<FileTypes, List<LocReport>>()); WorkDayHours = 8; WorkDayPerMonth = 20; WorkingMonths = 12; EffortAdjustmentFactor = 0.6; ProjectComplexity = 1.04; }
public static UberStrikeItemQuickView Deserialize(Stream bytes) { int mask = Int32Proxy.Deserialize(bytes); var view = new UberStrikeItemQuickView(); view.BehaviourType = EnumProxy <QuickItemLogic> .Deserialize(bytes); view.CoolDownTime = Int32Proxy.Deserialize(bytes); if ((mask & 1) != 0) { view.CustomProperties = DictionaryProxy <string, string> .Deserialize(bytes, StringProxy.Deserialize, StringProxy.Deserialize); } if ((mask & 2) != 0) { view.Description = StringProxy.Deserialize(bytes); } view.ID = Int32Proxy.Deserialize(bytes); view.IsConsumable = BooleanProxy.Deserialize(bytes); view.ItemClass = EnumProxy <UberStrikeItemClass> .Deserialize(bytes); if ((mask & 4) != 0) { view.ItemProperties = DictionaryProxy <ItemPropertyType, int> .Deserialize(bytes, EnumProxy <ItemPropertyType> .Deserialize, Int32Proxy.Deserialize); } view.LevelLock = Int32Proxy.Deserialize(bytes); view.MaxDurationDays = Int32Proxy.Deserialize(bytes); view.MaxOwnableAmount = Int32Proxy.Deserialize(bytes); if ((mask & 8) != 0) { view.Name = StringProxy.Deserialize(bytes); } if ((mask & 16) != 0) { view.PrefabName = StringProxy.Deserialize(bytes); } if ((mask & 32) != 0) { view.Prices = ListProxy <ItemPriceView> .Deserialize(bytes, ItemPriceViewProxy.Deserialize); } view.ShopHighlightType = EnumProxy <ItemShopHighlightType> .Deserialize(bytes); view.UsesPerGame = Int32Proxy.Deserialize(bytes); view.UsesPerLife = Int32Proxy.Deserialize(bytes); view.UsesPerRound = Int32Proxy.Deserialize(bytes); view.WarmUpTime = Int32Proxy.Deserialize(bytes); return(view); }
public static void Serialize(Stream stream, MapView instance) { var mask = 0; using (var bytes = new MemoryStream()) { if (instance.Description != null) { StringProxy.Serialize(bytes, instance.Description); } else { mask |= 1; } if (instance.DisplayName != null) { StringProxy.Serialize(bytes, instance.DisplayName); } else { mask |= 2; } BooleanProxy.Serialize(bytes, instance.IsBlueBox); Int32Proxy.Serialize(bytes, instance.MapId); Int32Proxy.Serialize(bytes, instance.MaxPlayers); Int32Proxy.Serialize(bytes, instance.RecommendedItemId); if (instance.SceneName != null) { StringProxy.Serialize(bytes, instance.SceneName); } else { mask |= 4; } if (instance.Settings != null) { DictionaryProxy <GameModeType, MapSettingsView> .Serialize(bytes, instance.Settings, EnumProxy <GameModeType> .Serialize, MapSettingsViewProxy.Serialize); } else { mask |= 8; } Int32Proxy.Serialize(bytes, instance.SupportedGameModes); Int32Proxy.Serialize(bytes, instance.SupportedItemClass); Int32Proxy.Serialize(stream, ~mask); bytes.WriteTo(stream); } }
public AssemblerImpl(ApplicationArchitecture <ApplicationModel <ApplicationSPI> > applicationArchitecture, Func <Int32> newCompositeIDRequestor, DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeSupport, UsesContainerMutable parentContainer, CollectionsFactory collectionsFactory) { ArgumentValidator.ValidateNotNull("Application architecture", applicationArchitecture); ArgumentValidator.ValidateNotNull("ID requestor function", newCompositeIDRequestor); ArgumentValidator.ValidateNotNull("Model type support", modelTypeSupport); ArgumentValidator.ValidateNotNull("Parent uses container", parentContainer); ArgumentValidator.ValidateNotNull("Collections factory", collectionsFactory); this._applicationArchitecture = applicationArchitecture; this._newCompositeIDRequestor = newCompositeIDRequestor; this._collectionsFactory = collectionsFactory; this._compositeInfos = this._collectionsFactory.NewDictionaryProxy <CompositeModelType, DictionaryWithRoles <Type, ListProxy <CompositeAssemblyInfo>, ListProxyQuery <CompositeAssemblyInfo>, ListQuery <CompositeAssemblyInfo> > >(); this._assemblyScopeSupport = modelTypeSupport; this._parentContainer = parentContainer; }
public static DamageEventView Deserialize(Stream bytes) { int mask = Int32Proxy.Deserialize(bytes); var instance = new DamageEventView(); instance.BodyPartFlag = ByteProxy.Deserialize(bytes); if ((mask & 1) != 0) { instance.Damage = DictionaryProxy <byte, byte> .Deserialize(bytes, ByteProxy.Deserialize, ByteProxy.Deserialize); } instance.DamageEffectFlag = Int32Proxy.Deserialize(bytes); instance.DamgeEffectValue = SingleProxy.Deserialize(bytes); return(instance); }
public static UberStrikeItemGearView Deserialize(Stream bytes) { var mask = Int32Proxy.Deserialize(bytes); var view = new UberStrikeItemGearView(); view.ArmorPoints = Int32Proxy.Deserialize(bytes); view.ArmorWeight = Int32Proxy.Deserialize(bytes); if ((mask & 1) != 0) { view.CustomProperties = DictionaryProxy <string, string> .Deserialize(bytes, StringProxy.Deserialize, StringProxy.Deserialize); } if ((mask & 2) != 0) { view.Description = StringProxy.Deserialize(bytes); } view.ID = Int32Proxy.Deserialize(bytes); view.IsConsumable = BooleanProxy.Deserialize(bytes); view.ItemClass = EnumProxy <UberStrikeItemClass> .Deserialize(bytes); if ((mask & 4) != 0) { view.ItemProperties = DictionaryProxy <ItemPropertyType, int> .Deserialize(bytes, EnumProxy <ItemPropertyType> .Deserialize, Int32Proxy.Deserialize); } view.LevelLock = Int32Proxy.Deserialize(bytes); view.MaxDurationDays = Int32Proxy.Deserialize(bytes); if ((mask & 8) != 0) { view.Name = StringProxy.Deserialize(bytes); } if ((mask & 16) != 0) { view.PrefabName = StringProxy.Deserialize(bytes); } if ((mask & 32) != 0) { view.Prices = ListProxy <ItemPriceView> .Deserialize(bytes, ItemPriceViewProxy.Deserialize); } view.ShopHighlightType = EnumProxy <ItemShopHighlightType> .Deserialize(bytes); return(view); }
public static AccountCompletionResultView Deserialize(Stream bytes) { int mask = Int32Proxy.Deserialize(bytes); var view = new AccountCompletionResultView(); if ((mask & 1) != 0) { view.ItemsAttributed = DictionaryProxy <int, int> .Deserialize(bytes, Int32Proxy.Deserialize, Int32Proxy.Deserialize); } if ((mask & 2) != 0) { view.NonDuplicateNames = ListProxy <string> .Deserialize(bytes, StringProxy.Deserialize); } view.Result = Int32Proxy.Deserialize(bytes); return(view); }
internal LayeredApplicationModelImmutable( LayeredArchitecture architecture, Type genericCompositePropertyMixin, Type genericCompositeEventMixin, Type genericFragmentBaseType, DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeAssemblyScopeSupport, out DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport, out DictionaryProxy <Int32, CompositeModel> models, out ListProxy <LayerModelMutable> topLevelLayers, out ListProxy <LayerModelMutable> allLayers ) : base(architecture, genericCompositePropertyMixin, genericCompositeEventMixin, genericFragmentBaseType, modelTypeAssemblyScopeSupport, out compositeModelTypeSupport, out models) { this._topLevelLayers = this.CollectionsFactory.NewListProxy <LayerModelMutable>(); this._allLayers = this.CollectionsFactory.NewListProxy <LayerModelMutable>(); topLevelLayers = this._topLevelLayers; allLayers = this._allLayers; }
protected ApplicationModelSkeletonImmutable( ApplicationArchitecture <ApplicationModel <ApplicationSPI> > architecture, Type genericCompositePropertyMixin, Type genericCompositeEventMixin, Type genericFragmentBaseType, DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeAssemblyScopeSupport, out DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport, out DictionaryProxy <Int32, CompositeModel> models ) { ArgumentValidator.ValidateNotNull("Application architecture", architecture); ArgumentValidator.ValidateNotNull("Generic composite property mixin", genericCompositePropertyMixin); ArgumentValidator.ValidateNotNull("Generic composite event mixin", genericCompositeEventMixin); ArgumentValidator.ValidateNotNull("Generic fragment base type", genericFragmentBaseType); this._injectionService = new InjectionServiceImpl(); this._genericCompositePropertyMixin = genericCompositePropertyMixin; this._genericCompositeEventMixin = genericCompositeEventMixin; this._genericFragmentBaseType = genericFragmentBaseType; this._collectionsFactory = architecture.CollectionsFactory; this._compositeModelTypeSupport = this._collectionsFactory.NewDictionaryProxy <CompositeModelType, CompositeModelTypeModelScopeSupport>(modelTypeAssemblyScopeSupport.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.CreateModelScopeSupport())).CQ; this._models = this._collectionsFactory.NewDictionaryProxy <Int32, CompositeModel>(); this._validationResult = new Lazy <ApplicationValidationResultIQ>(this.DoValidate, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); compositeModelTypeSupport = this._compositeModelTypeSupport; models = this._models; this._typeModelDic = new Lazy <DictionaryQuery <CompositeModel, CompositeTypeModel> >(() => this._collectionsFactory.NewDictionaryProxy(this.CompositeModels.Values .Select(cModel => Tuple.Create(cModel, ((CompositeValidationResultImmutable)this._validationResult.Value.CompositeValidationResults[cModel]).TypeModel)) .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2, ReferenceEqualityComparer <CompositeModel> .ReferenceBasedComparer)).CQ , System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); this._affectedAssemblies = new Lazy <SetQuery <Assembly> >(() => this._collectionsFactory.NewSetProxy(new HashSet <Assembly>( this._typeModelDic.Value .SelectMany(tModel => tModel.Key.PublicTypes .Concat(tModel.Value.PrivateCompositeTypeInfos.Keys) .Concat(tModel.Value.FragmentTypeInfos.Keys) .Concat(tModel.Value.ConcernInvocationTypeInfos.Keys) .Concat(tModel.Value.SideEffectInvocationTypeInfos.Keys)) .Select(type => type.GetAssembly()) )).CQ , System.Threading.LazyThreadSafetyMode.ExecutionAndPublication); }
internal SingletonApplicationModelImmutable( SingletonArchitecture architecture, Type genericCompositePropertyMixin, Type genericCompositeEventMixin, Type genericFragmentBaseType, DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeAssemblyScopeSupport, out DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport, out DictionaryProxy <Int32, CompositeModel> models, out SetProxy <CompositeModel> modelsForContainer, Assembler assembler ) : base(architecture, genericCompositePropertyMixin, genericCompositeEventMixin, genericFragmentBaseType, modelTypeAssemblyScopeSupport, out compositeModelTypeSupport, out models) { ArgumentValidator.ValidateNotNull("Assembler", assembler); this._assembler = assembler; this._compositeModels = this.CollectionsFactory.NewSetProxy <CompositeModel>(); modelsForContainer = this._compositeModels; }
protected DictionaryQuery <Type, InstancePoolInfo <TInvocation> > CreatePoolDictionary <TTypeGen, TInvocation>(Type[] gArgs, IEnumerable <TTypeGen> typeGenResults, CollectionsFactory collectionsFactory) where TTypeGen : TypeGenerationResult { DictionaryProxy <Type, InstancePoolInfo <TInvocation> > result = collectionsFactory.NewDictionaryProxy <Type, InstancePoolInfo <TInvocation> >(); foreach (var genResult in typeGenResults) { var genType = genResult.GeneratedType; if (gArgs != null) { genType = genType.MakeGenericType(gArgs); } else if (genType.ContainsGenericParameters()) { throw new InternalException("Could not find generic arguments for " + genResult.DeclaredType + "."); } result.Add(genType, new InstancePoolInfoImpl <TInvocation>(new InstancePool <TInvocation>(), genType, genResult)); } return(result.CQ); }
public static void Serialize(Stream stream, ApplicationConfigurationView instance) { int mask = 0; using (var bytes = new MemoryStream()) { Int32Proxy.Serialize(bytes, instance.MaxLevel); Int32Proxy.Serialize(bytes, instance.MaxXp); Int32Proxy.Serialize(bytes, instance.PointsBaseLoser); Int32Proxy.Serialize(bytes, instance.PointsBaseWinner); Int32Proxy.Serialize(bytes, instance.PointsHeadshot); Int32Proxy.Serialize(bytes, instance.PointsKill); Int32Proxy.Serialize(bytes, instance.PointsNutshot); Int32Proxy.Serialize(bytes, instance.PointsPerMinuteLoser); Int32Proxy.Serialize(bytes, instance.PointsPerMinuteWinner); Int32Proxy.Serialize(bytes, instance.PointsSmackdown); Int32Proxy.Serialize(bytes, instance.XpBaseLoser); Int32Proxy.Serialize(bytes, instance.XpBaseWinner); Int32Proxy.Serialize(bytes, instance.XpHeadshot); Int32Proxy.Serialize(bytes, instance.XpKill); Int32Proxy.Serialize(bytes, instance.XpNutshot); Int32Proxy.Serialize(bytes, instance.XpPerMinuteLoser); Int32Proxy.Serialize(bytes, instance.XpPerMinuteWinner); if (instance.XpRequiredPerLevel != null) { DictionaryProxy <int, int> .Serialize(bytes, instance.XpRequiredPerLevel, Int32Proxy.Serialize, Int32Proxy.Serialize); } else { mask |= 1; } Int32Proxy.Serialize(bytes, instance.XpSmackdown); Int32Proxy.Serialize(stream, ~mask); bytes.WriteTo(stream); } }
public static void Serialize(Stream stream, DamageEventView instance) { int mask = 0; using (var bytes = new MemoryStream()) { ByteProxy.Serialize(bytes, instance.BodyPartFlag); if (instance.Damage != null) { DictionaryProxy <byte, byte> .Serialize(bytes, instance.Damage, ByteProxy.Serialize, ByteProxy.Serialize); } else { mask |= 1; } Int32Proxy.Serialize(bytes, instance.DamageEffectFlag); SingleProxy.Serialize(bytes, instance.DamgeEffectValue); Int32Proxy.Serialize(stream, ~mask); bytes.WriteTo(stream); } }
internal LayerArchitectureImpl( LayeredArchitecture application, UsesContainerQuery parentContainer, Func <Int32> compositeIDGenerator, DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeSupport, String name, Action <LayerArchitecture[]> usageAction ) { ArgumentValidator.ValidateNotNull("Application", application); ArgumentValidator.ValidateNotNull("Model type support", modelTypeSupport); ArgumentValidator.ValidateNotNull("Composite ID Generator", compositeIDGenerator); ArgumentValidator.ValidateNotNull("Action to tell usage", usageAction); ArgumentValidator.ValidateNotNull("Parent meta-info container", parentContainer); this._application = application; this._compositeIDGenerator = compositeIDGenerator; this._usageAction = usageAction; this._layerName = name; this._modelTypeSupport = modelTypeSupport; this._metaInfo = UsesContainerMutableImpl.CreateWithParent(parentContainer); this._modules = application.CollectionsFactory.NewDictionaryProxy <String, ModuleArchitectureImpl>(); this._domainSpecificAssemblers = new DomainSpecificAssemblerAggregatorImpl <LayerArchitecture>(application.CollectionsFactory); }
private static void SetProperties(object target, DictionaryProxy options) { if (options == null) return; foreach (KeyValuePair<string, string> item in options.ToDictionary()) { PropertyInfo property = target.GetType().GetProperty(item.Key, typeof (string)); if (property != null) property.SetValue(target, item.Value); //else throw new Exception("Type: " + target.GetType().Name + " Property: " + item.Key); } }
/// <summary> /// Get a dictionary of proxies of the given <paramref name="targets"/>. /// </summary> /// <typeparam name="TKey"> /// Type of the dictionary key. /// </typeparam> /// <typeparam name="TValue"> /// Type of the dictionary value. /// </typeparam> /// <param name="targets"> /// A dictionary of original target objects. /// </param> /// <returns> /// A dictionary of proxies of targets or targets itself if it is already /// a dictionary of others. /// </returns> public static IDictionary <TKey, TValue> GetProxy <TKey, TValue>(IDictionary <TKey, TValue> targets) where TValue : class { return(DictionaryProxy <TKey, TValue> .GetProxy(targets)); }
/// <summary> /// Retrieve the target dictionary wrapped in <paramref name="proxies"/>. /// </summary> /// <typeparam name="TKey"> /// Type of the dictionary keys. /// </typeparam> /// <typeparam name="TValue"> /// Type of hte dictionary values. /// </typeparam> /// <param name="proxies"> /// An proxy dictionary returned by <see cref="GetProxy{TKey,TValue}(IDictionary{TKey,TValue})"/>. /// </param> /// <returns> /// The target dictionary instance wrapped by <paramref name="proxies"/>, /// or <paramref name="proxies"/> itself if it is actually not a proxy. /// </returns> public static IDictionary <TKey, TValue> GetTarget <TKey, TValue>(IDictionary <TKey, TValue> proxies) where TValue : class { return(DictionaryProxy <TKey, TValue> .GetTarget(proxies)); }
protected ModuleModelMutable NewModuleModel(DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport, DictionaryProxy <Int32, CompositeModel> models, LayerModelMutable owningLayer, ModuleArchitectureImpl module) { var state = new ModuleModelState(this.CollectionsFactory); var immutable = new ModuleModelImmutable(state); var result = new ModuleModelMutable(state, immutable); state.ModuleName = module.Name; state.LayerModel = owningLayer; state.Assembler = module.LayeredCompositeAssembler; foreach (var modelType in this.ModelTypeSupport.Keys) { IDictionary <CompositeModel, Visibility> visibilities = null; if (!state.CompositeVisibilities.TryGetValue(modelType, out visibilities)) { visibilities = new Dictionary <CompositeModel, Visibility>(ReferenceEqualityComparer <CompositeModel> .ReferenceBasedComparer); state.CompositeVisibilities.Add(modelType, visibilities); } foreach (LayeredCompositeAssemblyInfo info in module.LayeredCompositeAssembler.GetInfos(modelType).Cast <LayeredCompositeAssemblyInfo>()) { var cModel = this.NewCompositeModel(compositeModelTypeSupport, owningLayer.IQ.ApplicationModel, info, owningLayer.IQ.LayerName + "-" + module.Name); models.Add(cModel.CompositeModelID, cModel); state.CompositeModels.Add(cModel); visibilities.Add(cModel, info.Visibility); } } return(result); }
private void ProcessLayers(ApplicationValidationResultIQ validationResult, DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults, DictionaryProxy <LayerModel, LayerImpl> layers, LayerModel layerModel) { if (!layers.CQ.ContainsKey(layerModel)) { layers.Add(layerModel, new LayerImpl(validationResult, loadingResults, this, layerModel)); } foreach (LayerModel used in layerModel.UsedLayerModels) { this.ProcessLayers(validationResult, loadingResults, layers, used); } }
public static void Serialize(Stream stream, UberStrikeItemWeaponView instance) { int mask = 0; using (var bytes = new MemoryStream()) { Int32Proxy.Serialize(bytes, instance.AccuracySpread); Int32Proxy.Serialize(bytes, instance.CombatRange); Int32Proxy.Serialize(bytes, instance.CriticalStrikeBonus); if (instance.CustomProperties != null) { DictionaryProxy <string, string> .Serialize(bytes, instance.CustomProperties, new DictionaryProxy <string, string> .Serializer <string>(StringProxy.Serialize), new DictionaryProxy <string, string> .Serializer <string>(StringProxy.Serialize)); } else { mask |= 1; } Int32Proxy.Serialize(bytes, instance.DamageKnockback); Int32Proxy.Serialize(bytes, instance.DamagePerProjectile); Int32Proxy.Serialize(bytes, instance.DefaultZoomMultiplier); if (instance.Description != null) { StringProxy.Serialize(bytes, instance.Description); } else { mask |= 2; } BooleanProxy.Serialize(bytes, instance.HasAutomaticFire); Int32Proxy.Serialize(bytes, instance.ID); BooleanProxy.Serialize(bytes, instance.IsConsumable); EnumProxy <UberStrikeItemClass> .Serialize(bytes, instance.ItemClass); if (instance.ItemProperties != null) { DictionaryProxy <ItemPropertyType, int> .Serialize(bytes, instance.ItemProperties, EnumProxy <ItemPropertyType> .Serialize, Int32Proxy.Serialize); } else { mask |= 4; } Int32Proxy.Serialize(bytes, instance.LevelLock); Int32Proxy.Serialize(bytes, instance.MaxAmmo); Int32Proxy.Serialize(bytes, instance.MaxDurationDays); Int32Proxy.Serialize(bytes, instance.MaxZoomMultiplier); Int32Proxy.Serialize(bytes, instance.MinZoomMultiplier); Int32Proxy.Serialize(bytes, instance.MissileBounciness); Int32Proxy.Serialize(bytes, instance.MissileForceImpulse); Int32Proxy.Serialize(bytes, instance.MissileTimeToDetonate); if (instance.Name != null) { StringProxy.Serialize(bytes, instance.Name); } else { mask |= 8; } if (instance.PrefabName != null) { StringProxy.Serialize(bytes, instance.PrefabName); } else { mask |= 16; } if (instance.Prices != null) { ListProxy <ItemPriceView> .Serialize(bytes, instance.Prices, ItemPriceViewProxy.Serialize); } else { mask |= 32; } Int32Proxy.Serialize(bytes, instance.ProjectileSpeed); Int32Proxy.Serialize(bytes, instance.ProjectilesPerShot); Int32Proxy.Serialize(bytes, instance.RateOfFire); Int32Proxy.Serialize(bytes, instance.RecoilKickback); Int32Proxy.Serialize(bytes, instance.RecoilMovement); Int32Proxy.Serialize(bytes, instance.SecondaryActionReticle); EnumProxy <ItemShopHighlightType> .Serialize(bytes, instance.ShopHighlightType); Int32Proxy.Serialize(bytes, instance.SplashRadius); Int32Proxy.Serialize(bytes, instance.StartAmmo); Int32Proxy.Serialize(bytes, instance.Tier); Int32Proxy.Serialize(bytes, instance.WeaponSecondaryAction); Int32Proxy.Serialize(stream, ~mask); bytes.WriteTo(stream); } }
public ModelWithAttributesState(CollectionsFactory collectionsFactory) { this._allAttributes = collectionsFactory.NewListProxy <Attribute>(); this._attributes = collectionsFactory.NewDictionary <Type, ListProxy <Attribute>, ListProxyQuery <Attribute>, ListQuery <Attribute> >(); this._attributesOfAttributes = collectionsFactory.NewDictionaryProxy <Type, DictionaryWithRoles <Type, ListProxy <Attribute>, ListProxyQuery <Attribute>, ListQuery <Attribute> > >(); }
public static UberStrikeItemWeaponView Deserialize(Stream bytes) { int mask = Int32Proxy.Deserialize(bytes); var view = new UberStrikeItemWeaponView(); view.AccuracySpread = Int32Proxy.Deserialize(bytes); view.CombatRange = Int32Proxy.Deserialize(bytes); view.CriticalStrikeBonus = Int32Proxy.Deserialize(bytes); if ((mask & 1) != 0) { view.CustomProperties = DictionaryProxy <string, string> .Deserialize(bytes, StringProxy.Deserialize, StringProxy.Deserialize); } view.DamageKnockback = Int32Proxy.Deserialize(bytes); view.DamagePerProjectile = Int32Proxy.Deserialize(bytes); view.DefaultZoomMultiplier = Int32Proxy.Deserialize(bytes); if ((mask & 2) != 0) { view.Description = StringProxy.Deserialize(bytes); } view.HasAutomaticFire = BooleanProxy.Deserialize(bytes); view.ID = Int32Proxy.Deserialize(bytes); view.IsConsumable = BooleanProxy.Deserialize(bytes); view.ItemClass = EnumProxy <UberStrikeItemClass> .Deserialize(bytes); if ((mask & 4) != 0) { view.ItemProperties = DictionaryProxy <ItemPropertyType, int> .Deserialize(bytes, EnumProxy <ItemPropertyType> .Deserialize, Int32Proxy.Deserialize); } view.LevelLock = Int32Proxy.Deserialize(bytes); view.MaxAmmo = Int32Proxy.Deserialize(bytes); view.MaxDurationDays = Int32Proxy.Deserialize(bytes); view.MaxZoomMultiplier = Int32Proxy.Deserialize(bytes); view.MinZoomMultiplier = Int32Proxy.Deserialize(bytes); view.MissileBounciness = Int32Proxy.Deserialize(bytes); view.MissileForceImpulse = Int32Proxy.Deserialize(bytes); view.MissileTimeToDetonate = Int32Proxy.Deserialize(bytes); if ((mask & 8) != 0) { view.Name = StringProxy.Deserialize(bytes); } if ((mask & 16) != 0) { view.PrefabName = StringProxy.Deserialize(bytes); } if ((mask & 32) != 0) { view.Prices = ListProxy <ItemPriceView> .Deserialize(bytes, ItemPriceViewProxy.Deserialize); } view.ProjectileSpeed = Int32Proxy.Deserialize(bytes); view.ProjectilesPerShot = Int32Proxy.Deserialize(bytes); view.RateOfFire = Int32Proxy.Deserialize(bytes); view.RecoilKickback = Int32Proxy.Deserialize(bytes); view.RecoilMovement = Int32Proxy.Deserialize(bytes); view.SecondaryActionReticle = Int32Proxy.Deserialize(bytes); view.ShopHighlightType = EnumProxy <ItemShopHighlightType> .Deserialize(bytes); view.SplashRadius = Int32Proxy.Deserialize(bytes); view.StartAmmo = Int32Proxy.Deserialize(bytes); view.Tier = Int32Proxy.Deserialize(bytes); view.WeaponSecondaryAction = Int32Proxy.Deserialize(bytes); return(view); }
public static void Serialize(Stream stream, UberStrikeItemQuickView instance) { int mask = 0; using (var bytes = new MemoryStream()) { EnumProxy <QuickItemLogic> .Serialize(bytes, instance.BehaviourType); Int32Proxy.Serialize(bytes, instance.CoolDownTime); if (instance.CustomProperties != null) { DictionaryProxy <string, string> .Serialize(bytes, instance.CustomProperties, StringProxy.Serialize, StringProxy.Serialize); } else { mask |= 1; } if (instance.Description != null) { StringProxy.Serialize(bytes, instance.Description); } else { mask |= 2; } Int32Proxy.Serialize(bytes, instance.ID); BooleanProxy.Serialize(bytes, instance.IsConsumable); EnumProxy <UberStrikeItemClass> .Serialize(bytes, instance.ItemClass); if (instance.ItemProperties != null) { DictionaryProxy <ItemPropertyType, int> .Serialize(bytes, instance.ItemProperties, EnumProxy <ItemPropertyType> .Serialize, Int32Proxy.Serialize); } else { mask |= 4; } Int32Proxy.Serialize(bytes, instance.LevelLock); Int32Proxy.Serialize(bytes, instance.MaxDurationDays); Int32Proxy.Serialize(bytes, instance.MaxOwnableAmount); if (instance.Name != null) { StringProxy.Serialize(bytes, instance.Name); } else { mask |= 8; } if (instance.PrefabName != null) { StringProxy.Serialize(bytes, instance.PrefabName); } else { mask |= 16; } if (instance.Prices != null) { ListProxy <ItemPriceView> .Serialize(bytes, instance.Prices, ItemPriceViewProxy.Serialize); } else { mask |= 32; } EnumProxy <ItemShopHighlightType> .Serialize(bytes, instance.ShopHighlightType); Int32Proxy.Serialize(bytes, instance.UsesPerGame); Int32Proxy.Serialize(bytes, instance.UsesPerLife); Int32Proxy.Serialize(bytes, instance.UsesPerRound); Int32Proxy.Serialize(bytes, instance.WarmUpTime); Int32Proxy.Serialize(stream, ~mask); bytes.WriteTo(stream); } }
public static void Serialize(Stream stream, UberStrikeItemFunctionalView instance) { int mask = 0; using (var bytes = new MemoryStream()) { if (instance.CustomProperties != null) { DictionaryProxy <string, string> .Serialize(bytes, instance.CustomProperties, new DictionaryProxy <string, string> .Serializer <string>(StringProxy.Serialize), new DictionaryProxy <string, string> .Serializer <string>(StringProxy.Serialize)); } else { mask |= 1; } if (instance.Description != null) { StringProxy.Serialize(bytes, instance.Description); } else { mask |= 2; } Int32Proxy.Serialize(bytes, instance.ID); BooleanProxy.Serialize(bytes, instance.IsConsumable); EnumProxy <UberStrikeItemClass> .Serialize(bytes, instance.ItemClass); if (instance.ItemProperties != null) { DictionaryProxy <ItemPropertyType, int> .Serialize(bytes, instance.ItemProperties, EnumProxy <ItemPropertyType> .Serialize, Int32Proxy.Serialize); } else { mask |= 4; } Int32Proxy.Serialize(bytes, instance.LevelLock); Int32Proxy.Serialize(bytes, instance.MaxDurationDays); if (instance.Name != null) { StringProxy.Serialize(bytes, instance.Name); } else { mask |= 8; } if (instance.PrefabName != null) { StringProxy.Serialize(bytes, instance.PrefabName); } else { mask |= 16; } if (instance.Prices != null) { ListProxy <ItemPriceView> .Serialize(bytes, instance.Prices, ItemPriceViewProxy.Serialize); } else { mask |= 32; } EnumProxy <ItemShopHighlightType> .Serialize(bytes, instance.ShopHighlightType); Int32Proxy.Serialize(stream, ~mask); bytes.WriteTo(stream); } }
public void ApplicationConfigurationSerializationRountripTest() { ApplicationConfiguration config = new ApplicationConfiguration(); config.Name = "MyApplication"; config.Description = "A test application for TDD HIE"; { // Receive PortConfiguration port = new PortConfiguration(); config.Ports.Add(port); EndpointConfiguration endpoint = new EndpointConfiguration(); endpoint.TypeInfo = typeof (EndpointMock).GetTypeInfo().AssemblyQualifiedName; port.Endpoint = endpoint; PipelineComponentConfiguration encoder = new PipelineComponentConfiguration(); encoder.TypeInfo = typeof (PipelineComponentMock).GetTypeInfo().AssemblyQualifiedName; port.Encoders.Add(encoder); PipelineComponentConfiguration assembler = new PipelineComponentConfiguration(); assembler.TypeInfo = typeof (PipelineComponentMock).GetTypeInfo().AssemblyQualifiedName; port.Assemblers.Add(assembler); } { // Send EndpointConfiguration endpoint = new EndpointConfiguration(); var typeInfo = typeof (EndpointMock).GetTypeInfo(); endpoint.TypeInfo = typeInfo.AssemblyQualifiedName; PortConfiguration port = new PortConfiguration(); port.Endpoint = endpoint; config.Ports.Add(port); } { ChannelConfiguration channel = new ChannelConfiguration(); channel.Name = "Test channel"; channel.Description = "A test channel"; config.Channels.Add(channel); SourceConfiguration source = new SourceConfiguration(); channel.Source = source; { FilterConfiguration filter = new FilterConfiguration(); var typeInfo = typeof (DelegateFilter).GetTypeInfo(); filter.TypeInfo = typeInfo.AssemblyQualifiedName; DictionaryProxy options = new DictionaryProxy(new Dictionary<string, string>()); options.Add("property1", "value1&"); options.Add("property2", "value2\n\nvalue2"); options.Add("property3", "value3"); filter.Options = options; source.Filters.Add(filter); } { TransformerConfiguration transformer = new TransformerConfiguration(); var typeInfo = typeof (JavaScriptTransformer).GetTypeInfo(); transformer.TypeInfo = typeInfo.AssemblyQualifiedName; DictionaryProxy options = new DictionaryProxy(new Dictionary<string, string>()); options.Add("Script", "true"); transformer.Options = options; source.Transformers.Add(transformer); } DestinationConfiguration destination = new DestinationConfiguration(); channel.Destinations.Add(destination); { FilterConfiguration filter = new FilterConfiguration(); var typeInfo = typeof (DelegateFilter).GetTypeInfo(); filter.TypeInfo = typeInfo.AssemblyQualifiedName; destination.Filters.Add(filter); } { TransformerConfiguration transformer = new TransformerConfiguration(); var typeInfo = typeof (DelegateTransformer).GetTypeInfo(); transformer.TypeInfo = typeInfo.AssemblyQualifiedName; destination.Transformers.Add(transformer); } } config.Save("CreateConfigurationTest-output.xml"); //NOTE: EXPORT XML SCHEMA config.SaveSchema("CreateConfigurationTest-output.xsd"); // Read and assert ApplicationConfiguration resultConfig = ApplicationConfiguration.Load("CreateConfigurationTest-output.xml"); Assert.IsNotNull(resultConfig); Assert.IsNotNull(resultConfig.Ports); Assert.AreEqual(2, resultConfig.Ports.Count()); Assert.IsNotNull(resultConfig.Ports.First().Endpoint); Assert.IsNotNull(resultConfig.Ports.First().Encoders); Assert.AreEqual(1, resultConfig.Ports.First().Encoders.Count()); Assert.IsNotNull(resultConfig.Ports.First().Assemblers); Assert.AreEqual(1, resultConfig.Ports.First().Assemblers.Count()); Assert.IsNotNull(resultConfig.Channels); Assert.AreEqual(1, resultConfig.Channels.Count()); Assert.IsNotNull(resultConfig.Channels.First().Destinations); Assert.AreEqual(1, resultConfig.Channels.First().Destinations.Count()); Assert.IsNotNull(resultConfig.Channels.First().Destinations.First().Transformers); Assert.AreEqual(1, resultConfig.Channels.First().Destinations.First().Transformers.Count()); Assert.IsNotNull(resultConfig.Channels.First().Destinations.First().Filters); Assert.AreEqual(1, resultConfig.Channels.First().Destinations.First().Filters.Count()); Assert.IsNotNull(resultConfig.Channels.First().Source); Assert.IsNotNull(resultConfig.Channels.First().Source.Filters); Assert.AreEqual(1, resultConfig.Channels.First().Source.Filters.Count()); Assert.IsNotNull(resultConfig.Channels.First().Source.Transformers); Assert.AreEqual(1, resultConfig.Channels.First().Source.Transformers.Count()); // Options Assert.IsNotNull(resultConfig.Channels.First().Source.Filters.First().Options); Dictionary<string, string> deserializedProperties = resultConfig.Channels.First().Source.Filters.First().Options.ToDictionary(); Assert.IsNotNull(deserializedProperties); Assert.AreEqual(3, deserializedProperties.Count()); Assert.AreEqual("value1&", deserializedProperties["property1"]); deserializedProperties = resultConfig.Channels.First().Source.Transformers.First().Options.ToDictionary(); Assert.IsNotNull(deserializedProperties); Assert.AreEqual(1, deserializedProperties.Count()); Assert.AreEqual("true", deserializedProperties["Script"]); }