public static long Save <T>(T entity, IAdapterService adapterService = null) where T : IEntity, new() { var contextAdapterService = (adapterService ?? DataContext.GetAdapterService <T>()); //if (entity.Id <= 0 || entity.Saved == false) { if (entity.Id <= 0) { QueryInsertBuilder <T> query = Query.Insert <T>(entity); return(contextAdapterService.Insert(query)); } else { var id = Convert.ToInt64((long)entity.Id); QueryUpdateBuilder <T> query = Query.Update <T>(entity).Where(x => x.Id == id); var updateLines = contextAdapterService.Update(query); if (updateLines > 0) { return(id); } else { QueryInsertBuilder <T> queryInsert = Query.Insert <T>(entity); return(contextAdapterService.Insert(queryInsert)); // return -1; } } }
public CustomSolutionNode(IVsSolutionHierarchyNode node, Lazy <ITreeNode> parent, ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory, IAdapterService adapterService) : base(SolutionNodeKind.Custom, node, parent, nodeFactory, adapterService) { }
public static T Load <T>(long id, IAdapterService adapterService = null) where T : IEntity, new() { var contextAdapterService = (adapterService ?? DataContext.GetAdapterService <T>()); QueryFindOneBuilder <T> query = Query.FindOne <T>().Where(x => x.Id == id); return(contextAdapterService.FindOne <T>(query)); }
/// <summary> /// Initializes a new instance of the <see cref="FolderNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="parentNode">The parent node accessor.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public FolderNode(IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, Lazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.Folder, hierarchyNode, nodeFactory, adapter, solutionExplorer) { }
public IAdapterService GetAdapterServiceInstance() { IAdapterService adapterServiceInstance = null; try { var PossibleAdapterServiceInstance = Activator.CreateInstance(Type.GetType(this.AdapterServiceType)); if (PossibleAdapterServiceInstance is IAdapterService) { adapterServiceInstance = (IAdapterService)PossibleAdapterServiceInstance; } else { throw new System.Exception("The declared AdapterServiceType isn't an IAdapterService"); } } catch (Exception ex) { throw ex; throw new System.Exception("The declared AdapterServiceType doesn't exist."); } adapterServiceInstance.ConnectionString = ConnectionString; if (adapterServiceInstance == null) { throw new System.Exception("Adapter service was not registred"); } return(adapterServiceInstance); }
public static long Insert(ref T entity, IAdapterService adapterService = null) { var id = Insert(entity, adapterService); entity.Id = id; return(id); }
public PlayCommand(Storage storage, IAdapterService adapter) { _storage = storage; _adapter = adapter; Image = Resources.Play_48x48; ShortcutKeys = Keys.F5; Enabled = true; DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; ToolTipText = @"F5"; EventAggregator.Instance.Subscribe <StopAppEvent>(e => Enabled = true); EventAggregator.Instance.Subscribe <PlayAppEvent>(e => Enabled = false); EventAggregator.Instance.Subscribe <StorageAppEvent>(e => { if (e.ChangingType == FileChangingType.Loading || e.ChangingType == FileChangingType.Saving) { Enabled = false; } if (e.ChangingType == FileChangingType.LoadComplete || e.ChangingType == FileChangingType.SaveComplete) { Enabled = true; } }); }
public static T FindOne(long id, IAdapterService adapterService = null) { QueryFindOneBuilder <T> newQuery = new QueryFindOneBuilder <T>(); var returnQuery = newQuery.Where(query => query.Id == id); return((adapterService ?? ContextAdapterService).FindOne <T>(returnQuery)); }
public CachedAdapterService(IAdapterService adapterService, IMemoryCache memoryCache) { m_adapterService = adapterService; m_cache = memoryCache; m_cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromMinutes(1)); }
public ApiController(IAdapterService adapterService, IAdapterSettingService adapterSettingService, ILogService logService, IHostApplicationLifetime hostApplicationLifetime) { _adapterService = adapterService; _adapterSettingService = adapterSettingService; _logService = logService; _hostApplicationLifetime = hostApplicationLifetime; }
/// <summary> /// Initializes a new instance of the <see cref="ReferenceNodeFactory"/> class. /// </summary> /// <param name="childNodeFactory">The factory for nodes, used to construct child nodes automatically.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public ReferenceNodeFactory( [Named(DefaultHierarchyFactory.RegisterKey)] Lazy <ITreeNodeFactory <IVsSolutionHierarchyNode> > childNodeFactory, IAdapterService adapter) { this.childNodeFactory = childNodeFactory; this.adapter = adapter; }
/// <summary> /// Initializes a new instance of the <see cref="GenericNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="parentNode">The parent node accessor.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ISolutionExplorerNode.As{T}"/>.</param> public GenericNode(IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.Generic, hierarchyNode, nodeFactory, adapter, solutionExplorer) { }
/// <inheritdoc /> public CrmSystemMock(IAdapterService adapterService) { var contactService = new ContactFunctionality(); ContactFunctionality = contactService; LeadFunctionality = new LeadFunctionality(contactService, adapterService); }
/// <summary> /// Sets the singleton adapter service instance to use to implement the /// <see cref="As"/> extension method for the entire lifetime of the /// current application domain. /// </summary> public static void SetService(IAdapterService service) { if (AppDomain.CurrentDomain.GetData(Constants.GlobalStateIdentifier) != null) throw new NotSupportedException("Global adapter service can only be set once per application domain."); AppDomain.CurrentDomain.SetData(Constants.GlobalStateIdentifier, service); }
public static long Update(T entity, IAdapterService adapterService = null) { long id = Convert.ToInt64((long)entity.Id); var query = Query.Update <T>(entity).Where(x => x.Id == id); return((adapterService ?? ContextAdapterService).Update(query)); }
public static IAdapterService GetAdapterService(string typeNamespaceOrKey = null, string typeName = null) { //string index; IAdapterService adapter = null; if (typeNamespaceOrKey != null) { if (typeName != null) { adapter = GetAdapterServiceByIndex($"{typeNamespaceOrKey}.{typeName}"); if (adapter != null) { return(adapter); } } adapter = GetAdapterServiceByIndex($"{typeNamespaceOrKey}.*"); if (adapter != null) { return(adapter); } adapter = GetAdapterServiceByIndex(typeNamespaceOrKey); if (adapter != null) { return(adapter); } } return(GetDefaultAdapterService()); }
/// <summary> /// Initializes a new instance of the <see cref="FolderNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="parentNode">The parent node accessor.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public FolderNode(IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, Lazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.Folder, hierarchyNode, nodeFactory, adapter, solutionExplorer) { Folder = new Lazy <ProjectItem>(() => hierarchyNode.GetExtenderObject() as ProjectItem); }
public static bool Delete(T entity, IAdapterService adapterService = null) { //throw new NotImplementedException(); //TODO: need to be fixed. deletando tabela inteira long id = Convert.ToInt64(entity.Id); var query = Query.Delete <T>().Where(x => x.Id == (Value)id); return((adapterService ?? ContextAdapterService).Delete(query)); }
/// <summary> /// Initializes a new instance of the <see cref="ReferencesNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public ReferencesNode( IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.ReferencesFolder, hierarchyNode, nodeFactory, adapter, solutionExplorer) { }
/// <summary> /// Initializes a new instance of the <see cref="ProjectNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public ProjectNode( IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, Lazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.Project, hierarchyNode, nodeFactory, adapter, solutionExplorer) { properties = new Lazy <GlobalProjectProperties>(() => new GlobalProjectProperties(this)); }
/// <summary> /// Sets the singleton adapter service instance to use to implement the /// <see cref="As"/> extension method for the entire lifetime of the /// current application domain. /// </summary> public static void SetService(IAdapterService service) { if (AppDomain.CurrentDomain.GetData(Constants.GlobalStateIdentifier) != null) { throw new NotSupportedException("Global adapter service can only be set once per application domain."); } AppDomain.CurrentDomain.SetData(Constants.GlobalStateIdentifier, service); }
public GivenThreeAdaptersInHierarchy() { this.service = new AdapterService(new IAdapter[] { Mock.Of <IAdapter <IFrom, string> >(a => a.Adapt(It.IsAny <IFrom>()) == "from"), Mock.Of <IAdapter <IFrom2, string> >(a => a.Adapt(It.IsAny <IFrom2>()) == "from2"), Mock.Of <IAdapter <IFrom3, string> >(a => a.Adapt(It.IsAny <IFrom3>()) == "from3"), }); }
public FolderNodeFactory ( Lazy<ISolutionExplorerNodeFactory> childNodeFactory, IAdapterService adapter, [Import (ContractNames.Interop.SolutionExplorerWindow)] Lazy<IVsUIHierarchyWindow> solutionExplorer) { this.childNodeFactory = childNodeFactory; this.adapter = adapter; this.solutionExplorer = solutionExplorer; }
public static bool Delete <T>(T entity, IAdapterService adapterService = null) where T : IEntity, new() { //throw new NotImplementedException(); // TODO: testar delete ///// ---------------------- var contextAdapterService = (adapterService ?? DataContext.GetAdapterService <T>()); QueryDeleteBuilder <T> query = Query.Delete <T>(entity); return(contextAdapterService.Delete(query)); }
internal static void Initialize(IAdapterService service) { if (singleton.Value != null) { throw new InvalidOperationException("Already initialized."); } singleton.Value = service; }
public FolderNodeFactory( Lazy <ISolutionExplorerNodeFactory> childNodeFactory, IAdapterService adapter, [Import(ContractNames.Interop.SolutionExplorerWindow)] Lazy <IVsUIHierarchyWindow> solutionExplorer) { this.childNodeFactory = childNodeFactory; this.adapter = adapter; this.solutionExplorer = solutionExplorer; }
/// <summary> /// Initializes a new instance of the <see cref="ItemNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public ItemNode( IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.Item, hierarchyNode, nodeFactory, adapter, solutionExplorer) { properties = new Lazy <ItemProperties>(() => new ItemProperties(this)); }
public ItemNodeFactory( Lazy <ISolutionExplorerNodeFactory> childNodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer) { this.childNodeFactory = childNodeFactory; this.adapter = adapter; this.solutionExplorer = solutionExplorer; }
public GivenAConcreteTypeAdapter() { this.service = new AdapterService(new IAdapter[] { new ConcreteFromAdapter(), Mock.Of <IAdapter <IFrom, string> >(a => a.Adapt(It.IsAny <IFrom>()) == "from"), Mock.Of <IAdapter <IFrom2, string> >(a => a.Adapt(It.IsAny <IFrom2>()) == "from2"), Mock.Of <IAdapter <IFrom3, string> >(a => a.Adapt(It.IsAny <IFrom3>()) == "from3"), }); }
/// <summary> /// Initializes a new instance of the <see cref="SolutionFolderNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public SolutionFolderNode( IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.SolutionFolder, hierarchyNode, nodeFactory, adapter, solutionExplorer) { SolutionFolder = new Lazy <SolutionFolder>( () => (SolutionFolder)((Project)hierarchyNode.GetExtenderObject()).Object); }
public StopCommand(IAdapterService adapter) { _adapter = adapter; Image = Resources.Stop_48x48; Enabled = false; DisplayStyle = ToolStripItemDisplayStyle.Image; ToolTipText = @"F6"; ShortcutKeys = Keys.F6; EventAggregator.Instance.Subscribe <PlayAppEvent>(n => Enabled = true); EventAggregator.Instance.Subscribe <StopAppEvent>(n => Enabled = false); }
public ReferencesNodeFactory( Lazy <ISolutionExplorerNodeFactory> childNodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer, JoinableTaskContext jtc) { this.childNodeFactory = childNodeFactory; this.adapter = adapter; this.solutionExplorer = solutionExplorer; this.asyncManager = jtc.Factory; }
public SolutionExplorerNodeFactory( [ImportMany(ContractNames.FallbackNodeFactory)] IEnumerable<ICustomSolutionExplorerNodeFactory> defaultFactories, [ImportMany] IEnumerable<ICustomSolutionExplorerNodeFactory> customFactories, IAdapterService adapter, [Import(ContractNames.Interop.SolutionExplorerWindow)] Lazy<IVsUIHierarchyWindow> solutionExplorer) { this.defaultFactories = defaultFactories.ToList(); this.customFactories = customFactories.ToList (); this.adapter = adapter; this.solutionExplorer = solutionExplorer; }
/// <summary> /// Initializes a new instance of the <see cref="ProjectItemNode"/> class. /// </summary> /// <param name="kind">The kind of project node.</param> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ISolutionExplorerNode.As{T}"/>.</param> public ProjectItemNode( SolutionNodeKind kind, IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, Lazy<IVsUIHierarchyWindow> solutionExplorer) : base(kind, hierarchyNode, nodeFactory, adapter, solutionExplorer) { this.nodeFactory = nodeFactory; owningProject = new Lazy<IProjectNode>(() => this.nodeFactory.CreateNode(hierarchyNode.GetRoot ()) as IProjectNode); }
public SolutionNodeFactory( [Import (typeof (SVsServiceProvider))] IServiceProvider services, Lazy<ISolutionExplorerNodeFactory> nodeFactory, IAdapterService adapter, IVsSolutionSelection selection, [Import (ContractNames.Interop.SolutionExplorerWindow)] Lazy<IVsUIHierarchyWindow> solutionExplorer) { this.services = services; this.nodeFactory = nodeFactory; this.adapter = adapter; this.selection = selection; this.solutionExplorer = solutionExplorer; }
/// <summary> /// Initializes a new instance of the <see cref="ProjectItemNode"/> class. /// </summary> /// <param name="kind">The kind of project node.</param> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="parentNode">The parent node accessor.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public ProjectItemNode( SolutionNodeKind kind, IVsSolutionHierarchyNode hierarchyNode, Lazy<ITreeNode> parentNode, ITreeNodeFactory<IVsSolutionHierarchyNode> nodeFactory, IAdapterService adapter) : base(kind, hierarchyNode, parentNode, nodeFactory, adapter) { this.nodeFactory = nodeFactory; this.owningProject = new Lazy<IProjectNode>(() => { var owningHierarchy = new VsSolutionHierarchyNode(hierarchyNode.VsHierarchy, VSConstants.VSITEMID_ROOT); return this.nodeFactory.CreateNode(GetParent(owningHierarchy), owningHierarchy) as IProjectNode; }); }
public ProjectNodeFactory ( [Import(typeof(SVsServiceProvider))] IServiceProvider services, IVsHierarchyItemManager hierarchyManager, Lazy<ISolutionExplorerNodeFactory> childNodeFactory, IAdapterService adapter, [Import (ContractNames.Interop.SolutionExplorerWindow)] Lazy<IVsUIHierarchyWindow> solutionExplorer, [Import(Clide.ContractNames.Interop.IVsBooleanSymbolExpressionEvaluator)] Lazy<IVsBooleanSymbolExpressionEvaluator> expressionEvaluator) { solution = new Lazy<IVsSolution> (() => services.GetService<SVsSolution, IVsSolution> ()); this.hierarchyManager = hierarchyManager; this.childNodeFactory = childNodeFactory; this.adapter = adapter; this.solutionExplorer = solutionExplorer; this.expressionEvaluator = expressionEvaluator; }
/// <summary> /// Sets up a transient adapter service that remains active during /// an entire call chain, even across code that spawns new threads /// or tasks, but does not overwrite the global singleton service /// specified via <see cref="SetService"/>. /// </summary> /// <returns>A disposable object that removes the transient service when disposed.</returns> /// <remarks> /// Typical usage includes placing the call in a using statement: /// <code> /// using (AdaptersInitializer.SetTransientService(serviceMock)) /// { /// // Invoke code that uses the adapter service. /// } /// </code> /// </remarks> public static IDisposable SetTransientService(IAdapterService service) { transientService.Value = service; return new Disposable(() => transientService.Value = null); }
/// <summary> /// Sets the singleton adapter service instance to use to implement the /// <see cref="Adapters.Adapt"/> extension method for the entire lifetime of the /// current application domain. /// </summary> public static void SetService(IAdapterService service) { AppDomain.CurrentDomain.SetData(Constants.GlobalStateIdentifier, service); }
/// <summary> /// Initializes the <see cref="Adapt"/> static facade with /// the specified service. /// </summary> /// <param name="service">The adapter service to use on the <see cref="Adapt"/> class.</param> public static void Initialize(IAdapterService service) { Guard.NotNull(() => service, service); Adapt.Initialize(service); }
public DteToVsAdapterSpec (OpenSolution11Fixture fixture) { this.fixture = fixture; adapters = GlobalServiceLocator.Instance.GetExport<IAdapterService> (); }