protected override object DoGetInstance(Type serviceType, string key)
        {
            object    value = null;
            Exception e     = null;

            if (TryGetValue(serviceType, key, out value, out e))
            {
                return(value);
            }

            var item = Namespaces.FirstOrDefault(p => serviceType.Namespace.StartsWith(p));

            if (item != null)
            {
                var proxy = (IHttpProxy)Activator.CreateInstance(typeof(HttpRealProxy <>).MakeGenericType(serviceType));
                proxy.ClientProxy = GetHttpClient(item);

                var obj = proxy.BuildProxyInstance();
                RegisterValue(serviceType, key, obj);

                return(obj);
            }

            throw e;
        }
        private bool IsNamespaceActive(LogViewModel log)
        {
            // Try to get existing root namespace with name of application
            var nsApplication = Namespaces.FirstOrDefault(m => m.Name == log.Application);

            if (nsApplication == null)
            {
                return(false);
            }

            // Example: Verbosus.VerbTeX.View
            string nsLogFull = log.Namespace;
            // Example: Verbosus
            string nsLogPart = nsLogFull.Split(new string[] { Constants.NAMESPACE_SPLITTER }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
            // Try to get existing namespace with name Verbosus
            var ns = nsApplication.Children.FirstOrDefault(m => m.Name == nsLogPart);

            if (ns == null)
            {
                return(false);
            }
            if (nsLogFull.Contains(Constants.NAMESPACE_SPLITTER))
            {
                return(IsNamespaceActive(ns, nsLogFull.Substring(nsLogFull.IndexOf(Constants.NAMESPACE_SPLITTER) + 1)));
            }
            else
            {
                return(ns.IsChecked);
            }
        }
Exemple #3
0
        public NamespaceModel AddNamespace(string name)
        {
            var ns = Namespaces.FirstOrDefault(n => n.Name == name);

            if (ns == null)
            {
                ns = new NamespaceModel(this, name);
                Namespaces.Add(ns);
            }
            return(ns);
        }
Exemple #4
0
        internal Namespace GetOrCreateNamespaceByQName(string name)
        {
            var parts = name.Split(new[] { '.' });
            var ns    = Namespaces.FirstOrDefault(_ => _.Name == parts[0]);

            if (ns == null)
            {
                ns = new Namespace(name, this);
                _namespaces.Add(ns);
            }
            return(ns);
        }
Exemple #5
0
        public void AddType(OdcmType type)
        {
            string @namespace = type.Namespace.Name;

            OdcmNamespace odcmNamespace = Namespaces.FirstOrDefault(x => x.Name == @namespace);

            if (odcmNamespace == null)
            {
                odcmNamespace = new OdcmNamespace(@namespace);
                Namespaces.Add(odcmNamespace);
            }

            _Types.Add(type);

            odcmNamespace.Types.Add(type);
        }
        public override string ToString()
        {
            if (Namespaces?.FirstOrDefault() != null)
            {
                foreach (var ns in Namespaces)
                {
                    _stringBuilder.Append(ns + "\n");
                }
            }

            _stringBuilder.Append(welcomeText);
            _stringBuilder.Append($"\nnamespace {ClassNamespace}");
            _stringBuilder.Append("\n{");

            if (Attributes?.FirstOrDefault() != null)
            {
                foreach (var attribute in Attributes)
                {
                    _stringBuilder.Append("\n\t" + attribute);
                }
            }

            _stringBuilder.Append("\n\tpublic ");
            if (IsPartial)
            {
                _stringBuilder.Append("partial ");
            }

            _stringBuilder.Append($"class {ClassName}");
            if (Parents?.FirstOrDefault() != null)
            {
                _stringBuilder.Append(" : ");
                _stringBuilder.Append(string.Join(", ", Parents));
            }
            _stringBuilder.Append("\n\t{");

            if (Methods?.FirstOrDefault() != null)
            {
                foreach (var method in Methods)
                {
                    _stringBuilder.Append("\t" + method);
                }
            }

            _stringBuilder.Append("\n\t}\n}");
            return(_stringBuilder.ToString());
        }
        public CodeGenerationModel SetCurrentNamespace(string name)
        {
            _currentNamespace = Namespaces.FirstOrDefault(x => x.Name.Equals(name, StringComparison.Ordinal));

            if (_currentNamespace == null)
            {
                _currentNamespace = new ModelNamespace
                {
                    Model = this,
                    Name  = name,
                };

                Namespaces.Add(_currentNamespace);
            }

            return(this);
        }
        private void UpdateNamespaces(IEnumerable <LogViewModel> logsToInsert)
        {
            try {
                foreach (var log in logsToInsert)
                {
                    var application = Applications.FirstOrDefault(m => m.Name == log.Application);
                    if (application == null)
                    {
                        Logger.Error("[UpdateNamespaces] The application has to be set at this point.");
                        return;
                    }
                    // Try to get existing root namespace with name of application
                    var nsApplication = Namespaces.FirstOrDefault(m => m.Name == log.Application);
                    if (nsApplication == null)
                    {
                        nsApplication = new NamespaceViewModel(log.Application, application);
                        Namespaces.Add(nsApplication);
                    }

                    // Example: Verbosus.VerbTeX.View
                    string nsLogFull = log.Namespace;
                    // Example: Verbosus
                    string nsLogPart = nsLogFull.Split(new string[] { Constants.NAMESPACE_SPLITTER }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
                    // Try to get existing namespace with name Verbosus
                    var nsChild = nsApplication.Children.FirstOrDefault(m => m.Name == nsLogPart);
                    if (nsChild == null)
                    {
                        nsChild           = new NamespaceViewModel(nsLogPart, application);
                        nsChild.IsChecked = nsApplication.IsChecked;
                        nsApplication.Children.Add(nsChild);
                        nsChild.Parent = nsApplication;
                    }
                    if (nsLogFull.Contains(Constants.NAMESPACE_SPLITTER))
                    {
                        HandleNamespace(nsChild, nsLogFull.Substring(nsLogFull.IndexOf(Constants.NAMESPACE_SPLITTER) + 1), application, log);
                    }
                    else
                    {
                        SetLogCountByLevel(log, nsChild);
                    }
                }
            } catch (Exception e) {
                Console.WriteLine("Could not update namespaces: " + e);
            }
        }
Exemple #9
0
        public DotNetNamespaceRegion(IPluginServiceModel model, ModelItem modelItem, ISourceToolRegion <IPluginSource> source)
        {
            try
            {
                Errors                    = new List <string>();
                LabelWidth                = 74;
                ToolRegionName            = "DotNetNamespaceRegion";
                _modelItem                = modelItem;
                _model                    = model;
                _source                   = source;
                _source.SomethingChanged += SourceOnSomethingChanged;
                Dependants                = new List <IToolRegion>();
                IsRefreshing              = false;
                UpdateBasedOnSource();
                if (Namespace != null)
                {
                    SelectedNamespace = Namespaces.FirstOrDefault(item => item.FullName == Namespace.FullName);
                }
                RefreshNamespaceCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(() =>
                {
                    IsRefreshing = true;
                    if (_source.SelectedSource != null)
                    {
                        Namespaces = _modelItem.ItemType == typeof(DsfEnhancedDotNetDllActivity) ? _model.GetNameSpacesWithJsonRetunrs(_source.SelectedSource) : _model.GetNameSpaces(_source.SelectedSource);
                    }

                    IsRefreshing = false;
                }, CanRefresh);

                IsEnabled  = true;
                _modelItem = modelItem;
            }
            catch (Exception e)
            {
                Errors.Add(e.Message);
            }
        }
Exemple #10
0
        public override IMetaEntityExpressionTarget SelectTarget(string expressionPathNode)
        {
            if (MetaEntityTools.IsMultinodeExpressionPath(expressionPathNode))
            {
                return(this.SelectTargetByPath(expressionPathNode));
            }
            var head = Namespaces.FirstOrDefault(x => x.name.Equals(expressionPathNode));

            if (head == null)
            {
                MetaEntityNamespace item = new MetaEntityNamespace();
                item.name   = expressionPathNode;
                item.Parent = this;

                Namespaces.Add(item);
                head = item;
            }
            else
            {
                head.Parent = this;
            }

            return(head);
        }
Exemple #11
0
 public bool TryResolveNamespace(string @namespace, out OdcmNamespace odcmNamespace)
 {
     odcmNamespace = Namespaces.FirstOrDefault(x => x.CanonicalName().Equals(@namespace, StringComparison.InvariantCulture));
     return(odcmNamespace != null);
 }