public async Task <ActionResult> UpdateIndex(long id) { var service = new CustomerService(); var types = new TypesService(); var model = new CustomerModel(); var result = await service.ReadCustomerByIdOrName(id); if (result.Code == 200) { var documentTypes = await types.GetDocumentTypes(); var countries = await types.GetCountries(); var departments = await types.GetDepartments(result.Data.CountryId); var cities = await types.GetCities(result.Data.DepartmentId, result.Data.CountryId); model = result.Data; model.DocumentTypes = documentTypes.Data; model.Countries = countries.Data; model.Departments = departments.Data; model.Cities = cities.Data; } return(View(model)); }
// Generate an enum class from a MetaData.xml static void Main(string[] args) { // Get input data Console.WriteLine("### input data"); IList <VehicleTypeDto> vehicleTypes = new TypesService() .GetVehicleTypes(); vehicleTypes.ForEach(x => Console.WriteLine(x)); Console.WriteLine(); // Generate enumeration class Console.WriteLine("### generate class"); string className = "VehicleType"; string code = new CodeGenerator(Assembly.GetEntryAssembly().GetName().Name) .CreateClass(className, vehicleTypes); Console.WriteLine(code); Console.WriteLine("### add file to project"); new ProjectAppender(). AddFile(className, code); Console.WriteLine("### output new class"); // Output contains not the latest generated file! Project needs to be reloaded! // todo: Doesn't work if code is generated with errors or the file doesn't exist VehicleType.GetAll().ToList().ForEach(x => Console.WriteLine(x)); Console.ReadLine(); }
public async Task <ActionResult> GetCities(long countryId, long departmentId) { var service = new TypesService(); var deps = await service.GetCities(departmentId, countryId); return(Json(deps, JsonRequestBehavior.AllowGet)); }
public void SetUp() { _typesRepo = new Mock<ITypesRepository>(); _typesService = new TypesService(_typesRepo.Object); }
public void WhenGettingAllTypes_ShouldReturnEighteenType() { var allTypes = new TypesService(null).GetAllTypes().ToList(); allTypes.ShouldNotContain(PokemonType.Unknown); allTypes.Count().ShouldBe(18); }
/// <summary> /// use this method only when recreate a map or the map id the database is null /// </summary> /// <param name="MapName"></param> /// <param name="layers"></param> /// <param name="racks"></param> /// <param name="columns"></param> /// <returns></returns> public Entity.Map CreateNewMap(string MapName, int layers, int racks, int columns) { using (TransactionScope scope = new TransactionScope()) { Map = new Entity.Map(); Map.MapName = MapName; Map.RackCount = racks; Map.LayerCount = layers; Map.ColumnCount = columns; //first save map initial messages this.MapDictionaryService = new Repository.MapDictionaryService(); this.MapDictionaryService.InsertMap(Map); //Reset Zones' static color Zone.ResetRrandomColor(); //initial all services as the map reference for one InitialServices(Map); //create general types list List <Entity.Types> generalTypes = TypesService.LoadTypes(); if (generalTypes.Count == 0)//if there has no types in the database, create new and save from code { generalTypes = GetGeneralTypes(); this.TypesService.InsertTypes(generalTypes); } //ALERT!! must be constrainted here as the same name of all the GENERAL_TYPES, or will has logical error //ALERT!! you can modify and make contraint from "public class ItemTypesString" in this singleton class Entity.Types tt = Map.Types.Single(t => t.Name == ItemTypesString.ITEM_TYPE_DEFAULT_STORAGE); this._default_storage = tt; //then set mapitems, default type Id is zt's Type Id List <Entity.MapItems> additionMapItemList = new List <MapItems>(); for (int i = 0; i < layers; i++) { for (int j = 0; j < racks; j++) { for (int k = 0; k < columns; k++) { Entity.MapItems tmp = new Entity.MapItems(); DAL.MapItems DAL_tmp = new DAL.MapItems() { MapItemLayer = i, MapItemRack = j, MapItemColumn = k, TypeId = tt.Id, ZoneId = 0, CargowayId = 0, Status = (int)MapItems.MapItemStatus.STATUS_NOT_STORAGE }; tmp.DAL_SetMapItem(DAL_tmp); additionMapItemList.Add(tmp); } } } MapItemsService.InsertMapItems(additionMapItemList); scope.Complete(); } return(Map); }
/// <summary> /// Creates new instance of Workspace type /// </summary> internal Workspace(Guid snapshotId, TimeSpan timeout, INodeProvider <Guid, object, EdgeData> nodeProvider, IWorkspaceFacade commitTarget, ProxyCreatorService proxyCreatorService, TypesService typesService, IsolationLevel isolationLevel, IProxyMap immutableProxyMap) { this.workspaceId = Guid.NewGuid(); this.thread = Thread.CurrentThread; if (!typeof(TDataType).IsInterface) { throw new ArgumentException("Interface type expected: " + typeof(TDataType).AssemblyQualifiedName); } this.snapshotId = snapshotId; this.nodeProvider = nodeProvider; this.proxyCreatorService = proxyCreatorService; this.typesService = typesService; this.isolationLevel = isolationLevel; this.workspaceFacade = commitTarget; this.immutableProxyMap = immutableProxyMap; workspaceFacade.OpenWorkspace(workspaceId, snapshotId, isolationLevel, timeout); if (isolationLevel == IsolationLevel.ReadOnly) { // Rely directly on parent provider if read only this.objectInstancesService = new ObjectInstancesService(nodeProvider, typesService); this.immutableInstancesService = new ObjectInstancesService(nodeProvider, typesService); this.collectionInstancesService = new CollectionInstancesService(nodeProvider, typesService); this.dictionaryInstancesService = new DictionaryInstancesService(nodeProvider, typesService); } else { // Construct isolated provider for local changes var isolatedStorage = new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false); isolatedProvider = new IsolatedNodeProvider(nodeProvider, isolatedStorage, thread); this.objectInstancesService = new ObjectInstancesService(isolatedProvider, typesService); this.immutableInstancesService = new ObjectInstancesService(nodeProvider, typesService); this.collectionInstancesService = new CollectionInstancesService(isolatedProvider, typesService); this.dictionaryInstancesService = new DictionaryInstancesService(isolatedProvider, typesService); } this.runtimeProxyFacade = new RuntimeProxyFacade(typesService, objectInstancesService, immutableInstancesService, collectionInstancesService, new CollectionInstancesService(nodeProvider, typesService), dictionaryInstancesService, new DictionaryInstancesService(nodeProvider, typesService), mutableProxyMap, immutableProxyMap, proxyCreatorService); // Initialize root data proxy var rootObjectId = commitTarget.GetRootObjectId(snapshotId); rootProxy = proxyCreatorService.NewObject <TDataType>(runtimeProxyFacade, rootObjectId, isolationLevel == IsolationLevel.ReadOnly); if (isolationLevel == IsolationLevel.ReadOnly) { immutableProxyMap.AddProxy(rootObjectId, rootProxy); } else { mutableProxyMap.AddProxy(rootObjectId, rootProxy); } }
public RuntimeProxyFacade(TypesService typesService, ObjectInstancesService objectInstancesService, ObjectInstancesService immutableInstancesService, CollectionInstancesService collectionInstancesService, CollectionInstancesService immutableCollectionInstancesService, DictionaryInstancesService dictionaryInstancesService, DictionaryInstancesService immutableDictionaryInstancesService, IProxyMap mutableProxyMap, IProxyMap immutableProxyMap, ProxyCreatorService proxyCreatorService) { this.objectInstancesService = objectInstancesService; this.immutableInstancesService = immutableInstancesService; this.collectionInstancesService = collectionInstancesService; this.dictionaryInstancesService = dictionaryInstancesService; this.immutableCollectionInstancesService = immutableCollectionInstancesService; this.immutableDictionaryInstancesService = immutableDictionaryInstancesService; this.mutableProxyMap = mutableProxyMap; this.immutableProxyMap = immutableProxyMap; this.proxyCreatorService = proxyCreatorService; this.typesService = typesService; }
/// <summary> /// Initializes the ProxyFacade class /// </summary> /// <param name="typesService">Service for type manipulation</param> public static void Initialize(TypesService typesService) { if (typesService == null) { throw new ArgumentNullException("typesService"); } StaticProxyFacade inst = new StaticProxyFacade(); inst.typesService = typesService; instance = inst; // Instance initialized }
public TypeViewModel(Type type, TypesService typesService) { DeferValidationUntilFirstSaveCall = false; _modelBackup = type.CreateBackup(); _typesService = typesService; Type = type; RedirectTargets = _typesService.GetRedirectTargets(type); TypesRedirectingToThis = (from t in Type.GlobalTypes where t.RedirectType == type orderby t.FullTypeName select t).ToList(); AllowRedirect = TypesRedirectingToThis.Count == 0; }
public async Task <ActionResult> CreateIndex() { var service = new TypesService(); var model = new CustomerModel(); var documentsTypes = await service.GetDocumentTypes(); var countries = await service.GetCountries(); model.DocumentTypes = documentsTypes.Data; model.Countries = countries.Data; return(View(model)); }
public async Task <ActionResult> DeleteIndex(long id) { var service = new CustomerService(); var types = new TypesService(); var model = new CustomerModel(); var result = await service.ReadCustomerByIdOrName(id); if (result.Code == 200) { model = result.Data; } return(View(model)); }
public TypesCharacteristicsViewModel(DataPersisterService dataPersisterService, GlobalService globalService, IUIVisualizerService visualizerService, IViewModelFactory viewModelFactory, CharacteristicsService characteristicsService, TypesService typesService, IAdvancedMessageService advancedMessageService) { _dataPersisterService = dataPersisterService; _visualizerService = visualizerService; _viewModelFactory = viewModelFactory; _globalService = globalService; _characteristicsService = characteristicsService; _typesService = typesService; _advancedMessageService = advancedMessageService; Title = "Edit Types / Characteristics"; AddTypeCommand = new TaskCommand(OnAddTypeCommandExecuteAsync); EditTypeCommand = new TaskCommand(OnEditTypeCommandExecuteAsync, EditTypeCanExecute); DeleteTypeCommand = new TaskCommand(OnDeleteTypeCommandExecuteAsync, DeleteTypeCanExecute); ShowTypeUsageCommand = new TaskCommand(OnShowTypeUsageCommandExecuteAsync, ShowTypeUsageCanExecute); AddCharacteristicCommand = new TaskCommand(OnAddCharacteristicCommandExecuteAsync); EditCharacteristicCommand = new TaskCommand(OnEditCharacteristicCommandExecuteAsync, EditCharacteristicCanExecute); DeleteCharacteristicCommand = new TaskCommand(OnDeleteCharacteristicCommandExecuteAsync, DeleteCharacteristicCanExecute); ShowCharacteristicUsageCommand = new TaskCommand(OnShowCharacteristicUsageCommandExecuteAsync, ShowCharacteristicUsageCanExecute); SelectedTypes.CollectionChanged += SelectedTypesOnCollectionChanged; SelectedCharacteristics.CollectionChanged += SelectedCharacteristicsOnCollectionChanged; Types = _typesService.TypeUsages; Characteristics = _characteristicsService.CharacteristicUsages; _characteristicsService.UpdateCharacteristicsUsages(); _typesService.UpdateTypesUsages(); TypesView = (ListCollectionView)CollectionViewSource.GetDefaultView(_typesService.TypeUsages); TypesView.IsLiveSorting = false; TypesView.IsLiveFiltering = false; CharacteristicsView = (ListCollectionView)CollectionViewSource.GetDefaultView( _characteristicsService.CharacteristicUsages); CharacteristicsView.IsLiveSorting = false; CharacteristicsView.IsLiveFiltering = false; }
private void InitializeServices() { typesService = new TypesService(provider); var interfaceToTypeIdMapping = typesService.InitializeTypeSystem(serverContext.EntityTypes); var completeTypesList = interfaceToTypeIdMapping.Keys; generationService = new GenerationService(typesService); // TODO (nsabo) Optional loading of proxy types from the given assembly (we dont want always to generate on small devices, Silverlight...) // Note: Collection/Dictionary types are not saved in the assembly var interfaceToGeneratedMapping = generationService.GenerateProxyTypes(completeTypesList, Properties.Settings.Default.SaveGeneratedAssemblyToDisk, Properties.Settings.Default.GeneratedAssemblyFileName); proxyCreatorService = new ProxyCreatorService(completeTypesList, interfaceToTypeIdMapping, interfaceToGeneratedMapping); StaticProxyFacade.Initialize(typesService); }
public void GivenADoubleWeakPokemon_MultiplierShouldBeCorrect( PokemonType moveType, PokemonType defendingPokemonType1, PokemonType defendingPokemonType2, float expectedMultiplier) { var defendingPokemon = new Pokemon() { Types = new[] { defendingPokemonType1, defendingPokemonType2 } }; var attackingMove = new QuickMove() { Type = moveType }; var effectivenessSource = CreateEffectivenessSource(); var typeService = new TypesService(effectivenessSource); typeService.GetTypeAdvantageMultiplier(attackingMove, defendingPokemon).Result.ShouldBe(expectedMultiplier); }
private async void LoadTypes() { var result = await TypesService.GetAll(); result.ForEach(x => Types.Add(x)); }
private void InitializeServices(Type rootEntityType, Type[] entityTypes, UpgradeConfiguration upgradeConfiguration) { this.rootEntityType = rootEntityType; this.entityTypes = entityTypes; typesService = new TypesService(provider); objectSerializationService.TypesService = typesService; var interfaceToTypeIdMapping = typesService.InitializeTypeSystem(entityTypes); var completeTypesList = interfaceToTypeIdMapping.Keys; generationService = new GenerationService(typesService); // TODO (nsabo) Optional loading of proxy types from the given assembly (we dont want always to generate on small devices, Silverlight...) // Note: Collection/Dictionary types are not saved in the assembly var interfaceToGeneratedMapping = generationService.GenerateProxyTypes(completeTypesList, Properties.Settings.Default.SaveGeneratedAssemblyToDisk, Properties.Settings.Default.GeneratedAssemblyFileName); proxyCreatorService = new ProxyCreatorService(completeTypesList, interfaceToTypeIdMapping, interfaceToGeneratedMapping); snapshotsService = new SnapshotsService(provider); #region Parent map provider setup if (Properties.Settings.Default.ParentMappingFileStorageUsed) { // Usage of file for caching parent information var indexedFile = new IndexedFileStorage(new FileStream(this.parentMappingFileName, FileMode.Create), Properties.Settings.Default.ParentMappingFileBlockSize, false); indexedFile.Serializer = this.objectSerializationService; disposables.Add(indexedFile); var parentProviderStorage = new CachedWriteNodeProviderUnsafe <Guid, object, EdgeData>( new DirectNodeProviderUnsafe <Guid, object, EdgeData>(indexedFile, true), new LimitedDirectNodeProviderUnsafe <Guid, object, EdgeData>( new LimitedMemoryStorageUnsafe <Guid, object>(Properties.Settings.Default.ParentMappingMemoryMinimumCount, Properties.Settings.Default.ParentMappingMemoryMaximumCount), false) ); disposables.Add(parentProviderStorage); mutableParentProvider = new ParentMapProvider(parentProviderStorage, provider, null, true); } else { // Default parent information is stored in memory and has only the last snapshot available mutableParentProvider = new ParentMapProvider(new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false), provider, null, true); } #endregion #region Merge rule provider setup IMergeRuleProvider mergeRuleProvider = null; if (SnapshotIsolationEnabled) { if (Properties.Settings.Default.ConcurrencyAutoOverrideResolution) { mergeRuleProvider = new AutoOverrideMergeRuleProvider(); } else { if (Properties.Settings.Default.ConcurrencyAttributesEnabled) { mergeRuleProvider = new AttributeBasedMergeRuleProvider(typesService); } else { throw new ArgumentException("No selected provider for merge rules in snapshot isolation conflicts. Check configuration of merge rule providers."); } } } #endregion #region Setup change set provider // TODO (nsabo) Provide option for change set safety when context goes offline, OfflineWorkspaces should enable commits when context is back online if (Properties.Settings.Default.ChangeSetHistoryFileStorageUsed) { var indexedFile = new IndexedFileStorage(new FileStream(Properties.Settings.Default.ChangeSetHistoryFileStorageFileName, FileMode.Create), 256, false); indexedFile.Serializer = this.objectSerializationService; disposables.Add(indexedFile); var changeSetProviderStorage = new CachedWriteNodeProviderUnsafe <Guid, object, EdgeData>( new DirectNodeProviderUnsafe <Guid, object, EdgeData>(indexedFile, true), new LimitedDirectNodeProviderUnsafe <Guid, object, EdgeData>( new LimitedMemoryStorageUnsafe <Guid, object>(Properties.Settings.Default.ChangeSetHistoryWriteCacheMinimumCount, Properties.Settings.Default.ChangeSetHistoryWriteCacheMaximumCount), false) ); disposables.Add(changeSetProviderStorage); changeSetProvider = new TrackingChangeSetProvider(changeSetProviderStorage); } else { changeSetProvider = new TrackingChangeSetProvider(new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false)); } #endregion var immutableParentProvider = new ParentMapProvider(new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false), provider, null, false); collectedNodesProvider = new CollectedNodesProvider(new DirectNodeProviderUnsafe <Guid, object, EdgeData>(new MemoryStorageUnsafe <Guid, object>(), false), provider); commitDataService = new CommitDataService(provider, typesService, snapshotsService, mutableParentProvider, immutableParentProvider, changeSetProvider, new NodeMergeExecutor(mergeRuleProvider, typesService), collectedNodesProvider); workspaceExclusiveLockProvider = new WorkspaceExclusiveLockProvider(); disposables.Add(workspaceExclusiveLockProvider); trackingWorkspaceStateProvider = new TrackingWorkspaceStateProvider(workspaceExclusiveLockProvider); objectInstancesService = new ObjectInstancesService(provider, typesService); subscriptionManagerService = new SubscriptionManagerService(typesService, objectInstancesService); workspaceFacade = new WorkspaceFacade(commitDataService, trackingWorkspaceStateProvider, subscriptionManagerService, snapshotsService, workspaceExclusiveLockProvider); backupService = new BackupService(); bool firstRun = snapshotsService.InitializeSnapshots(); if (firstRun) { InitializeDefaultSnapshot(); } else { OptimizeData(); } StaticProxyFacade.Initialize(typesService); }
private static void LogObject(Guid nodeId, Node <Guid, object, EdgeData> node, INodeProvider <Guid, object, EdgeData> nodes, INodeProvider <Guid, object, EdgeData> changes, int tabLevel, Hashtable visited, TypesService typesService) { var typeId = typesService.GetInstanceTypeId(node); var typeName = typesService.GetTypeFromId(typeId).Name; Debug.WriteLine(LogTabs(tabLevel) + nodeId + "(" + typeName + ")"); Debug.WriteLine(LogTabs(tabLevel) + "Previous=" + node.Previous); foreach (var value in node.Values) { Debug.WriteLine(LogTabs(tabLevel) + typesService.GetMemberName(typeId, value.Key) + "=" + value.Value); } foreach (var edge in node.Edges) { if (edge.Value.Data.Semantic == EdgeType.Property) { Debug.WriteLine(LogTabs(tabLevel) + typesService.GetMemberName(typeId, (Guid)edge.Value.Data.Data) + "="); LogNodesRecursive(edge.Value.ToNodeId, nodes, changes, tabLevel + 1, visited, typesService); } } }
public NodeMergeExecutor(IMergeRuleProvider objectAttributeProvider, TypesService typesService) { this.objectAttributeProvider = objectAttributeProvider; this.typesService = typesService; }
internal static void LogNodesRecursive(Guid nodeId, INodeProvider <Guid, object, EdgeData> nodes, INodeProvider <Guid, object, EdgeData> changes, int tabLevel, Hashtable visited, TypesService typesService) { if (visited.ContainsKey(nodeId)) { Debug.WriteLine(LogTabs(tabLevel) + nodeId); return; } visited.Add(nodeId, null); if (changes.Contains(nodeId)) { var node = changes.GetNode(nodeId, NodeAccess.Read); switch (node.NodeType) { case NodeType.Object: LogObject(nodeId, node, nodes, changes, tabLevel, visited, typesService); break; case NodeType.Collection: LogCollection(nodeId, node, nodes, changes, tabLevel, visited, typesService); break; case NodeType.Dictionary: LogCollection(nodeId, node, nodes, changes, tabLevel, visited, typesService); break; default: Debug.WriteLine(LogTabs(tabLevel) + node.Previous + "->" + nodeId + "[" + node.NodeType + "]"); foreach (var edge in node.Edges) { Debug.WriteLine(LogTabs(tabLevel) + edge.Key + "="); LogNodesRecursive(edge.Value.ToNodeId, nodes, changes, tabLevel + 1, visited, typesService); } break; } } else { Debug.WriteLine(LogTabs(tabLevel) + nodeId); } }
private static void LogCollection(Guid nodeId, Node <Guid, object, EdgeData> node, INodeProvider <Guid, object, EdgeData> nodes, INodeProvider <Guid, object, EdgeData> changes, int tabLevel, Hashtable visited, TypesService typesService) { Edge <Guid, EdgeData> typeEdge = null; BPlusTreeOperations.TryFindEdge(nodes, nodeId, new EdgeData(EdgeType.OfType, null), out typeEdge); var typeId = typeEdge.ToNodeId; var typeName = typesService.GetTypeFromId(typeId).Name; Debug.WriteLine(LogTabs(tabLevel) + nodeId + "(" + typeName + ")"); Debug.WriteLine(LogTabs(tabLevel) + "Previous=" + node.Previous); using (var enumeration = BPlusTreeOperations.GetEnumerator(nodes, nodeId, EdgeType.ListItem)) { while (enumeration.MoveNext()) { Debug.WriteLine(LogTabs(tabLevel) + enumeration.Current.Data + "="); LogNodesRecursive(enumeration.Current.ToNodeId, nodes, changes, tabLevel + 1, visited, typesService); } } }
/// <summary> /// Creates new instance of GenerationService type /// </summary> /// <param name="typesService">Type service to use</param> public GenerationService(TypesService typesService) { this.typesService = typesService; }
public AttributeBasedMergeRuleProvider(TypesService typesService) { this.typesService = typesService; Initialize(); }
public void SetUp() { _typesRepo = new Mock <ITypesRepository>(); _typesService = new TypesService(_typesRepo.Object); }
/// <summary> /// Creates new instance of SubscriptionManagerService type /// </summary> /// <param name="typesService">Service which manages types</param> /// <param name="objectInstancesService">Service which handles object instances</param> public SubscriptionManagerService(TypesService typesService, ObjectInstancesService objectInstancesService) { this.typesService = typesService; this.objectInstancesService = objectInstancesService; }