Esempio n. 1
0
        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;
                }
            }
        }
Esempio n. 2
0
 public CustomSolutionNode(IVsSolutionHierarchyNode node,
                           Lazy <ITreeNode> parent,
                           ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
                           IAdapterService adapterService)
     : base(SolutionNodeKind.Custom, node, parent, nodeFactory, adapterService)
 {
 }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 /// <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)
 {
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public static long Insert(ref T entity, IAdapterService adapterService = null)
        {
            var id = Insert(entity, adapterService);

            entity.Id = id;
            return(id);
        }
Esempio n. 7
0
        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;
                }
            });
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
 public CachedAdapterService(IAdapterService adapterService, IMemoryCache memoryCache)
 {
     m_adapterService    = adapterService;
     m_cache             = memoryCache;
     m_cacheEntryOptions = new MemoryCacheEntryOptions()
                           .SetSlidingExpiration(TimeSpan.FromMinutes(1));
 }
Esempio n. 10
0
 public ApiController(IAdapterService adapterService, IAdapterSettingService adapterSettingService, ILogService logService, IHostApplicationLifetime hostApplicationLifetime)
 {
     _adapterService          = adapterService;
     _adapterSettingService   = adapterSettingService;
     _logService              = logService;
     _hostApplicationLifetime = hostApplicationLifetime;
 }
Esempio n. 11
0
 /// <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;
 }
Esempio n. 12
0
 /// <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)
 {
 }
Esempio n. 13
0
        /// <inheritdoc />
        public CrmSystemMock(IAdapterService adapterService)
        {
            var contactService = new ContactFunctionality();

            ContactFunctionality = contactService;
            LeadFunctionality    = new LeadFunctionality(contactService, adapterService);
        }
Esempio n. 14
0
        /// <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);
        }
Esempio n. 15
0
        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));
        }
Esempio n. 16
0
        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());
        }
Esempio n. 17
0
 /// <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);
 }
Esempio n. 18
0
        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));
        }
Esempio n. 19
0
 /// <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)
 {
 }
Esempio n. 20
0
 /// <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));
 }
Esempio n. 21
0
        /// <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);
        }
Esempio n. 22
0
 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"),
     });
 }
Esempio n. 23
0
		public FolderNodeFactory (
			Lazy<ISolutionExplorerNodeFactory> childNodeFactory, 
			IAdapterService adapter,
			[Import (ContractNames.Interop.SolutionExplorerWindow)] Lazy<IVsUIHierarchyWindow> solutionExplorer)
		{
			this.childNodeFactory = childNodeFactory;
			this.adapter = adapter;
			this.solutionExplorer = solutionExplorer;
		}
Esempio n. 24
0
        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));
        }
Esempio n. 25
0
        internal static void Initialize(IAdapterService service)
        {
            if (singleton.Value != null)
            {
                throw new InvalidOperationException("Already initialized.");
            }

            singleton.Value = service;
        }
Esempio n. 26
0
 public FolderNodeFactory(
     Lazy <ISolutionExplorerNodeFactory> childNodeFactory,
     IAdapterService adapter,
     [Import(ContractNames.Interop.SolutionExplorerWindow)] Lazy <IVsUIHierarchyWindow> solutionExplorer)
 {
     this.childNodeFactory = childNodeFactory;
     this.adapter          = adapter;
     this.solutionExplorer = solutionExplorer;
 }
Esempio n. 27
0
 /// <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));
 }
Esempio n. 28
0
 public ItemNodeFactory(
     Lazy <ISolutionExplorerNodeFactory> childNodeFactory,
     IAdapterService adapter,
     JoinableLazy <IVsUIHierarchyWindow> solutionExplorer)
 {
     this.childNodeFactory = childNodeFactory;
     this.adapter          = adapter;
     this.solutionExplorer = solutionExplorer;
 }
Esempio n. 29
0
 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"),
     });
 }
Esempio n. 30
0
 /// <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);
 }
Esempio n. 31
0
 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);
 }
Esempio n. 32
0
 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;
 }
Esempio n. 33
0
		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;
		}
Esempio n. 34
0
		/// <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);
		}
Esempio n. 35
0
		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;
		}
Esempio n. 36
0
		/// <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;
			});
		}
Esempio n. 37
0
		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);
 }
Esempio n. 40
0
        /// <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);
        }
Esempio n. 41
0
		public DteToVsAdapterSpec (OpenSolution11Fixture fixture)
		{
			this.fixture = fixture;
			adapters = GlobalServiceLocator.Instance.GetExport<IAdapterService> ();
		}