Ejemplo n.º 1
0
    public CloneableList <T> Clone()
    {
        var result = new CloneableList <T>();

        result.AddRange(this.Select(item => (T)item.Clone()));
        return(result);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterTrigger"/> class.
 /// </summary>
 public FilterTrigger()
     : base("filterTrigger")
 {
     _weekDays  = null;
     _startTime = new TimeSpan(0, 0, 0);
     _endTime   = new TimeSpan(23, 59, 59);
 }
        /// <summary>
        /// Find all objects related to the target object in any special relationship type.
        /// </summary>
        /// <param name="objectId"></param>
        /// <returns></returns>
        public IEnumerable<RelationshipObject> FindAllRelationship(Guid objectId)
        {
            CloneableList<RelationshipObject> results = base.GetCacheObject<CloneableList<RelationshipObject>>(objectId);
            if (results != null) return results;

            using (MembershipDataContext ctx = DataContextFactory.Create<MembershipDataContext>())
            {
                List<Relationship> relationships = (from r in ctx.Relationships
                                                    where r.ApplicationId == authenticationContext.ApplicationId
                                                       && (r.ObjectXId == objectId || r.ObjectYId == objectId)
                                                    orderby r.Ordinal ascending
                                                    select r).ToList();

                HashSet<string> processedKeyValuePair = new HashSet<string>();
                results = new CloneableList<RelationshipObject>();
                foreach (Relationship relationship in relationships)
                {
                    Guid relatedObjectId = objectId != relationship.ObjectXId ? relationship.ObjectXId : relationship.ObjectYId;
                    string key = string.Format(CultureInfo.InvariantCulture, "{0}::{1}", relationship.RelationshipType, relatedObjectId);
                    if (processedKeyValuePair.Contains(key)) continue;

                    processedKeyValuePair.Add(key);
                    results.Add(new RelationshipObject
                    {
                        RelationshipType = relationship.RelationshipType,
                        ReferenceObjectId = relatedObjectId,
                        Ordinal = relationship.Ordinal
                    });
                }

                base.AddCache(objectId, results);
            }

            return results;
        }
Ejemplo n.º 4
0
        public void AddCacheEntry(DnsCacheEntry curEntry)
        {
            // todo: should we check if teh entry lookes as if it was blocked?

            CloneableList <DnsCacheEntry> curEntries = GetEntriesFor(curEntry.HostName);

            DnsCacheEntry oldEntry = null;

            if (curEntry.RecordType == DnsApi.DnsRecordType.A || curEntry.RecordType == DnsApi.DnsRecordType.AAAA)
            {
                oldEntry = curEntries.FirstOrDefault(e => { return(e.RecordType == curEntry.RecordType && MiscFunc.IsEqual(e.Address, curEntry.Address)); });
            }
            else // CNAME, SRV, MX, DNAME
            {
                oldEntry = curEntries.FirstOrDefault(e => { return(e.RecordType == curEntry.RecordType && MiscFunc.IsEqual(e.ResolvedString, curEntry.ResolvedString)); });
            }

            if (oldEntry == null)
            {
                AddCacheEntry(curEntries, curEntry);
            }
            else // just update
            {
                oldEntry.ExpirationTime = curEntry.ExpirationTime;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Converts the given value object to the specified type, using the specified context and culture information.
 /// </summary>
 /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
 /// <param name="culture">A <see cref="T:System.Globalization.CultureInfo"></see>. If null is passed, the current culture is assumed.</param>
 /// <param name="value">The <see cref="T:System.Object"></see> to convert.</param>
 /// <param name="destinationType">The <see cref="T:System.Type"></see> to convert the value parameter to.</param>
 /// <returns>
 /// An <see cref="T:System.Object"></see> that represents the converted value.
 /// </returns>
 /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
 /// <exception cref="T:System.ArgumentNullException">The destinationType parameter is null. </exception>
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         StringBuilder             str = new StringBuilder();
         CloneableList <DayOfWeek> lst = (CloneableList <DayOfWeek>)context.PropertyDescriptor.GetValue(context.Instance);
         if (lst == null || lst.Count == 0)
         {
             return("(Default)");
         }
         else
         {
             foreach (DayOfWeek item in lst)
             {
                 str.Append(string.Format("{0},", item.ToString()));
             }
             if (str.Length > 0)
             {
                 str.Remove(str.Length - 1, 1);
             }
             return(str.ToString());
         }
     }
     else
     {
         throw new NotSupportedException(string.Format("Unsupported type: {0}", destinationType.ToString()));
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Converts the given value object to the specified type, using the specified context and culture information.
 /// </summary>
 /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
 /// <param name="culture">A <see cref="T:System.Globalization.CultureInfo"></see>. If null is passed, the current culture is assumed.</param>
 /// <param name="value">The <see cref="T:System.Object"></see> to convert.</param>
 /// <param name="destinationType">The <see cref="T:System.Type"></see> to convert the value parameter to.</param>
 /// <returns>
 /// An <see cref="T:System.Object"></see> that represents the converted value.
 /// </returns>
 /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
 /// <exception cref="T:System.ArgumentNullException">The destinationType parameter is null. </exception>
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (value != null)
     {
         if (destinationType == typeof(String))
         {
             CloneableList <string> lst = (CloneableList <string>)value;
             StringBuilder          sb  = new StringBuilder();
             foreach (string s in lst)
             {
                 sb.Append(string.Format("{0};", s));
             }
             if (sb.Length > 0)
             {
                 sb.Length = sb.Length - 1;
             }
             return(sb.ToString());
         }
         else
         {
             throw new NotSupportedException(string.Format("Can not convert {0} to {1}", destinationType.ToString(), value.GetType().ToString()));
         }
     }
     else
     {
         return(string.Empty);
     }
 }
Ejemplo n.º 7
0
        private void OnHostName(IPAddress remoteAddress, string hostName, NameSources source, int processId = 0)
        {
            CloneableList <HostObserveJob> Jobs = ObserverJobs.GetValues(remoteAddress, false);

            if (Jobs == null)
            {
                return;
            }

            foreach (HostObserveJob curJob in Jobs.Clone())
            {
                if (processId == 0 || curJob.processId == processId)
                {
                    if (hostName != null)
                    {
                        curJob.SetHostName(hostName, source);
                    }
                    curJob.Await &= ~source; // clear the await
                }

                if (!curJob.IsValid())
                {
                    ObserverJobs.Remove(remoteAddress, curJob);
                }
            }
        }
Ejemplo n.º 8
0
        void OnLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnLoaded;

            var qtModules = QtModules.Instance.GetAvailableModuleInformation()
                            .Where((QtModuleInfo mi) => mi.Selectable)
                            .Select((QtModuleInfo mi) => new Module()
            {
                Name       = mi.Name,
                Id         = mi.proVarQT,
                IsSelected = Data.DefaultModules.Contains(mi.LibraryPrefix),
                IsReadOnly = Data.DefaultModules.Contains(mi.LibraryPrefix),
            });

            qtVersionList = new[] { QT_VERSION_DEFAULT, QT_VERSION_BROWSE }
            .Union(QtVersionManager.The().GetVersions());

            if (defaultQtVersionInfo == null)
            {
                Validate();
                return;
            }

            defaultConfigs = new CloneableList <Config> {
                new Config {
                    Name          = "Debug",
                    IsDebug       = true,
                    QtVersion     = defaultQtVersionInfo,
                    QtVersionName = defaultQtVersionInfo.name,
                    Target        = defaultQtVersionInfo.isWinRT()
                        ? ProjectTargets.WindowsStore.Cast <string>()
                        : ProjectTargets.Windows.Cast <string>(),
                    Platform = defaultQtVersionInfo.is64Bit()
                        ? ProjectPlatforms.X64.Cast <string>()
                        : ProjectPlatforms.Win32.Cast <string>(),
                    Modules = qtModules.ToDictionary((Module m) => m.Name),
                },
                new Config {
                    Name          = "Release",
                    IsDebug       = false,
                    QtVersion     = defaultQtVersionInfo,
                    QtVersionName = defaultQtVersionInfo.name,
                    Target        = defaultQtVersionInfo.isWinRT()
                        ? ProjectTargets.WindowsStore.Cast <string>()
                        : ProjectTargets.Windows.Cast <string>(),
                    Platform = defaultQtVersionInfo.is64Bit()
                        ? ProjectPlatforms.X64.Cast <string>()
                        : ProjectPlatforms.Win32.Cast <string>(),
                    Modules = qtModules.ToDictionary((Module m) => m.Name),
                }
            };
            currentConfigs          = defaultConfigs.Clone();
            ConfigTable.ItemsSource = currentConfigs;

            initialNextButtonIsEnabled   = NextButton.IsEnabled;
            initialFinishButtonIsEnabled = FinishButton.IsEnabled;

            Validate();
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EmailPublisher"/> class.
 /// </summary>
 public EmailPublisher( )
     : base("email")
 {
     _users          = new CloneableList <User> ( );
     _groups         = new CloneableList <Group> ( );
     this.Converters = new CloneableList <Converter> ( );
     this.ModifierNotificationTypes = new CloneableList <EmailNotificationType> ( );
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Deserialize(XmlElement element)
        {
            this.BaseDirectory       = string.Empty;
            this.BuildArguments      = string.Empty;
            this.BuildTimeoutSeconds = null;
            this.SuccessExitCodes    = null;
            this.Environment         = new CloneableList <EnvironmentVariable>();
            this._exe = string.Empty;

            if (string.Compare(element.Name, this.TypeName, false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to convert {0} to a {1}", element.Name, this.TypeName));
            }

            this.Executable = Util.GetElementOrAttributeValue("executable", element);

            string s = Util.GetElementOrAttributeValue("baseDirectory", element);

            if (!string.IsNullOrEmpty(s))
            {
                this.BaseDirectory = s;
            }

            s = Util.GetElementOrAttributeValue("buildArgs", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.BuildArguments = s;
            }

            s = Util.GetElementOrAttributeValue("buildTimeoutSeconds", element);
            if (!string.IsNullOrEmpty(s))
            {
                int i = 0;
                if (int.TryParse(s, out i))
                {
                    this.BuildTimeoutSeconds = i;
                }
            }

            s = Util.GetElementOrAttributeValue("successExitCodes", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.SuccessExitCodes = s;
            }

            XmlElement ele = (XmlElement)element.SelectSingleNode("environment");

            if (ele != null)
            {
                foreach (XmlElement ele1 in ele.SelectNodes("./*"))
                {
                    EnvironmentVariable ev = new EnvironmentVariable();
                    ev.Deserialize(ele1);
                    this.Environment.Add(ev);
                }
            }
        }
Ejemplo n.º 11
0
    public CloneableList <TValue> GetValues(TKey key, bool returnEmptySet = true)
    {
        CloneableList <TValue> toReturn = null;

        if (!base.TryGetValue(key, out toReturn) && returnEmptySet)
        {
            toReturn = new CloneableList <TValue>();
        }
        return(toReturn);
    }
Ejemplo n.º 12
0
    public CloneableList <TValue> Clone() // shallow copy!
    {
        CloneableList <TValue> clone = new CloneableList <TValue>();

        foreach (TValue v in this)
        {
            clone.Add(v);
        }
        return(clone);
    }
Ejemplo n.º 13
0
    public void Add(TKey key, TValue value)
    {
        CloneableList <TValue> container = null;

        if (!this.TryGetValue(key, out container))
        {
            container = new CloneableList <TValue>();
            base.Add(key, container);
        }
        container.Add(value);
    }
Ejemplo n.º 14
0
        private CloneableList <DnsCacheEntry> GetEntriesFor(string HostName)
        {
            CloneableList <DnsCacheEntry> curEntries = null; // all entries for thisdomain name

            if (!dnsCache.TryGetValue(HostName, out curEntries))
            {
                curEntries = new CloneableList <DnsCacheEntry>();
                dnsCache.Add(HostName, curEntries);
            }
            return(curEntries);
        }
Ejemplo n.º 15
0
    public bool ContainsValue(TKey key, TValue value)
    {
        bool toReturn = false;
        CloneableList <TValue> values = null;

        if (this.TryGetValue(key, out values))
        {
            toReturn = values.Contains(value);
        }
        return(toReturn);
    }
Ejemplo n.º 16
0
    public CloneableList <TValue> GetOrAdd(TKey key)
    {
        CloneableList <TValue> toReturn = null;

        if (!base.TryGetValue(key, out toReturn))
        {
            toReturn = new CloneableList <TValue>();
            base.Add(key, toReturn);
        }
        return(toReturn);
    }
Ejemplo n.º 17
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Deserialize(System.Xml.XmlElement element)
        {
            this.Arguments      = string.Empty;
            this.AutoGetSource  = null;
            this.Environment    = new CloneableList <EnvironmentVariable> ( );
            this.LabelOnSuccess = null;
            this.Timeout        = new Timeout( );

            if (string.Compare(element.GetAttribute("type"), this.TypeName, false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to convert {0} to a {1}", element.GetAttribute("type"), this.TypeName));
            }

            this.Executable = Util.GetElementOrAttributeValue("executable", element);

            string s = Util.GetElementOrAttributeValue("labelOnSuccess", element);

            if (!string.IsNullOrEmpty(s))
            {
                this.LabelOnSuccess = string.Compare(s, bool.TrueString, true) == 0;
            }

            s = Util.GetElementOrAttributeValue("autoGetSource", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.AutoGetSource = string.Compare(s, bool.TrueString, true) == 0;
            }

            s = Util.GetElementOrAttributeValue("args", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.Arguments = s;
            }

            XmlElement ele = ( XmlElement )element.SelectSingleNode("timeout");

            if (ele != null)
            {
                this.Timeout.Deserialize(ele);
            }

            ele = ( XmlElement )element.SelectSingleNode("environment");
            if (ele != null)
            {
                foreach (XmlElement ele1 in ele.SelectNodes("./*"))
                {
                    EnvironmentVariable ev = new EnvironmentVariable( );
                    ev.Deserialize(ele1);
                    this.Environment.Add(ev);
                }
            }
        }
Ejemplo n.º 18
0
    public CloneableList <TValue> GetAllValues()
    {
        CloneableList <TValue> toReturn = new CloneableList <TValue>();

        foreach (List <TValue> values in this.Values)
        {
            foreach (TValue value in values)
            {
                toReturn.Add(value);
            }
        }
        return(toReturn);
    }
Ejemplo n.º 19
0
    public void Remove(TKey key, TValue value)
    {
        CloneableList <TValue> container = null;

        if (this.TryGetValue(key, out container))
        {
            container.Remove(value);
            if (container.Count <= 0)
            {
                this.Remove(key);
            }
        }
    }
Ejemplo n.º 20
0
        public void CloneableListCloneTest( )
        {
            CloneableList <PublisherTask> tasks = new CloneableList <PublisherTask> ( );
            NullTask t = new NullTask();

            tasks.Add(t);

            CloneableList <PublisherTask> tasksClone = tasks.Clone( );

            tasks.Remove(t);
            Assert.IsNotNull(tasksClone, "Tasks Clone is Null");
            Assert.IsNotEmpty(tasksClone, "Tasks Clone is Empty");
            Console.WriteLine("Task Clone Count = {0}", tasksClone.Count);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>
        /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed.
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (frmsvr != null)
            {
                // create the listbox
                CheckedListBox lst = new CheckedListBox();
                // hide the border
                lst.BorderStyle = BorderStyle.None;
                // attach some events
                lst.ItemCheck += new ItemCheckEventHandler(OnListBoxItemCheck);
                // set so when item clicked, it checks/unchecks
                lst.CheckOnClick = true;

                CloneableList <DayOfWeek> objValue = (CloneableList <DayOfWeek>)value;
                // add a "Default" item
                lst.Items.Add("(Default)", false);
                // here we add all the DayOfWeek items to the listbox
                // checking if any are already in the value that we have, if so, set checked to true.
                foreach (DayOfWeek dow in Enum.GetValues(typeof(DayOfWeek)))
                {
                    lst.Items.Add(dow, objValue != null ? objValue.IndexOf(dow) > -1 : false);
                }

                // create our output variable
                CloneableList <DayOfWeek> values = new CloneableList <DayOfWeek> ();
                // show the dropdown
                frmsvr.DropDownControl(lst);

                // get the items that are checked
                foreach (object o in lst.CheckedItems)
                {
                    // if it is a DayOfWeek and not the String we added then add it to the out variable
                    if (o.GetType() == typeof(DayOfWeek))
                    {
                        values.Add((DayOfWeek)o);
                    }
                }

                if (lst.CheckedItems.Count == 0 || lst.GetItemChecked(0))
                {
                    return(null);
                }
                else
                {
                    return(values);
                }
            }
            return(value);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Deserialize(System.Xml.XmlElement element)
        {
            this._assemblies = new CloneableList <string> ( );
            this.OutputFile  = string.Empty;
            this._nunitPath  = string.Empty;
            this.RunnerPath  = string.Empty;
            this.Timeout     = null;

            if (string.Compare(element.Name, this.TypeName, false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to convert {0} to a {1}", element.Name, this.TypeName));
            }

            XmlElement ele = ( XmlElement )element.SelectSingleNode("assemblies");

            if (ele != null)
            {
                foreach (XmlElement aele in ele.SelectNodes("assembly"))
                {
                    this.Assemblies.Add(aele.InnerText);
                }
            }

            string s = Util.GetElementOrAttributeValue("nunitPath", element);

            this.NUnitPath = s;

            s = Util.GetElementOrAttributeValue("runnerPath", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.RunnerPath = s;
            }

            s = Util.GetElementOrAttributeValue("outputfile", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.OutputFile = s;
            }

            s = Util.GetElementOrAttributeValue("timeout", element);
            if (!string.IsNullOrEmpty(s))
            {
                int i = 0;
                if (int.TryParse(s, out i))
                {
                    this.Timeout = i;
                }
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Gets the CCNet versions.
        /// </summary>
        /// <returns></returns>
        internal static CloneableList <Version> GetCCNetVersions( )
        {
            CloneableList <Version> versions = new CloneableList <Version> ( );
            XmlDocument             doc      = new XmlDocument( );
            FileInfo file = new FileInfo(System.IO.Path.Combine(Application.StartupPath, Program.Configuration["CCNetVersions"].Path));

            if (file.Exists)
            {
                doc.Load(file.FullName);
                foreach (XmlElement ele in doc.DocumentElement.SelectNodes("Version"))
                {
                    versions.Add(new Version(ele.InnerText));
                }
            }
            return(versions);
        }
Ejemplo n.º 24
0
        public void Process()
        {
            // if we are using the DNS proxy we have first hand data and not need to monitor the system DNS cache.
            if (App.engine.DnsProxy == null || App.GetConfigInt("DnsInspector", "AlwaysMonitor", 0) != 0)
            {
                dnsCacheMonitor.SyncCache();
            }

            if (LastCleanupTime.AddMinutes(15) < DateTime.Now) // every 15 minutes
            {
                LastCleanupTime = DateTime.Now;

                queryWatcher.CleanupCache();
                dnsCacheMonitor.CleanupCache();
                hostNameResolver.CleanupCache();
            }

            foreach (var Address in ObserverJobs.Keys.ToList())
            {
                CloneableList <HostObserveJob> curJobs = ObserverJobs[Address];
                for (int i = 0; i < curJobs.Count; i++)
                {
                    HostObserveJob curJob = curJobs[i];

                    // Note: the cache emits events on every record found, if we have to a CNAME -> A -> IP case
                    //          we need to wait untill all records are in the cache and than properly search it
                    if ((curJob.Await & NameSources.CachedQuery) != 0)
                    {
                        string cachedName = FindMostRecentHost(dnsCacheMonitor.FindHostNames(curJob.remoteAddress));
                        if (cachedName != null)
                        {
                            curJob.SetHostName(cachedName, NameSources.CapturedQuery);
                        }
                        curJob.Await &= ~NameSources.CachedQuery; // if after one cache update we still dont have a result we wont get it
                    }

                    if (!curJob.IsValid())
                    {
                        curJobs.RemoveAt(i--);
                    }
                }
                if (curJobs.Count == 0)
                {
                    ObserverJobs.Remove(Address);
                }
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>
        /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed.
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (frmsvr != null)
            {
                Panel panel = new Panel();
                panel.Dock = DockStyle.Fill;
                Label lbl = new Label();
                lbl.Text     = "Enter Strings, 1 item per line:";
                lbl.AutoSize = true;
                lbl.Dock     = DockStyle.Top;

                TextBox tb = new TextBox();
                tb.Multiline     = true;
                tb.ScrollBars    = ScrollBars.Both;
                tb.AcceptsReturn = true;
                tb.Dock          = DockStyle.Fill;
                panel.Controls.Add(tb);
                panel.Controls.Add(lbl);

                if (value != null)
                {
                    List <string> lst = (List <string>)value;
                    foreach (string s in lst)
                    {
                        tb.AppendText(string.Format("{0}\r\n", s));
                    }
                }


                frmsvr.DropDownControl(panel);

                string result = tb.Text.Trim();
                if (!string.IsNullOrEmpty(result))
                {
                    string[] array             = result.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                    CloneableList <string> lst = new CloneableList <string> ();
                    lst.AddRange(array);
                    return(lst);
                }
                else
                {
                    return(value);
                }
            }
            return(value);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Deserialize(XmlElement element)
        {
            this.Actions = new CloneableList <string> ( );
            if (string.Compare(element.Name, this.TypeName, false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to convert {0} to a {1}", element.Name, this.TypeName));
            }
            XmlElement ele = ( XmlElement )element.SelectSingleNode("actions");

            if (ele != null)
            {
                foreach (XmlElement tele in ele.SelectNodes("action"))
                {
                    this.Actions.Add(tele.InnerText);
                }
            }
        }
Ejemplo n.º 27
0
        private void OnHostName(int processId, IPAddress remoteAddress, string hostName)
        {
            CloneableList <HostObserveJob> Jobs = ObserverJobs.GetValues(remoteAddress, false);

            if (Jobs == null)
            {
                return;
            }
            foreach (HostObserveJob Job in Jobs.Clone())
            {
                if (Job.processId == processId)
                {
                    Job.SetHostName(hostName, NameSources.CapturedQuery);
                }
                else if (Job.IsValid())
                {
                    continue;
                }
                ObserverJobs.Remove(remoteAddress, Job);
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Converts the given object to the type of this converter, using the specified context and culture information.
 /// </summary>
 /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
 /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"></see> to use as the current culture.</param>
 /// <param name="value">The <see cref="T:System.Object"></see> to convert.</param>
 /// <returns>
 /// An <see cref="T:System.Object"></see> that represents the converted value.
 /// </returns>
 /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     if (value != null)
     {
         if (value.GetType() == typeof(String))
         {
             string[] split             = ((string)value).Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
             CloneableList <string> lst = new CloneableList <string> ();
             lst.AddRange(split);
             return(lst);
         }
         else
         {
             return(value);
         }
     }
     else
     {
         return(value);
     }
 }
Ejemplo n.º 29
0
        private void AddCacheEntry(CloneableList <DnsCacheEntry> curEntries, DnsCacheEntry curEntry)
        {
            curEntries.Add(curEntry);

            if ((curEntry.RecordType == DnsApi.DnsRecordType.A || curEntry.RecordType == DnsApi.DnsRecordType.AAAA) && curEntry.Address != null)
            {
                if (curEntry.Address != null)
                {
                    cacheByIP.Add(curEntry.Address, curEntry);
                }
            }
            else if (curEntry.ResolvedString != null) // CNAME, SRV, MX, DNAME
            {
                if (curEntry.ResolvedString != null)
                {
                    cacheByStr.Add(curEntry.ResolvedString, curEntry);
                }
            }

            DnsCacheEvent?.Invoke(this, new DnsEvent()
            {
                Entry = curEntry
            });
        }
Ejemplo n.º 30
0
        public void CleanupCache()
        {
            DateTime ExpirationLimit = DateTime.Now.AddMinutes(App.GetConfigInt("DnsInspector", "CacheRetention", 15));

            foreach (var Name in dnsCache.Keys.ToList())
            {
                CloneableList <DnsCacheEntry> curEntries = dnsCache[Name];
                for (int i = 0; i < curEntries.Count; i++)
                {
                    DnsCacheEntry curEntry = curEntries[i];
                    if (curEntry.ExpirationTime < ExpirationLimit)
                    {
                        if (curEntry.RecordType == DnsApi.DnsRecordType.A || curEntry.RecordType == DnsApi.DnsRecordType.AAAA)
                        {
                            if (curEntry.Address != null)
                            {
                                cacheByIP.Remove(curEntry.Address, curEntry);
                            }
                        }
                        else // CNAME, SRV, MX, DNAME
                        {
                            if (curEntry.ResolvedString != null)
                            {
                                cacheByStr.Remove(curEntry.ResolvedString, curEntry);
                            }
                        }

                        curEntries.RemoveAt(i--);
                    }
                }
                if (curEntries.Count == 0)
                {
                    dnsCache.Remove(Name);
                }
            }
        }
        private IEnumerable<HierarchyDataObject> GetAllHierarchyDataInternal(string hierarchyType)
        {
            Kit.NotNull(hierarchyType, "hierarchyType");

            CloneableList<HierarchyDataObject> results = base.GetCacheObject<CloneableList<HierarchyDataObject>>(hierarchyType);
            if (results == null)
            {
                using (MembershipDataContext ctx = DataContextFactory.Create<MembershipDataContext>())
                {
                    List<HierarchyData> entities = (from hd in ctx.HierarchyDatas
                                                    where hd.ApplicationId == this.authenticationContext.ApplicationId && hd.HierarchyType == hierarchyType
                                                    select hd).ToList();

                    results = new CloneableList<HierarchyDataObject>();
                    foreach (HierarchyData entity in entities)
                    {
                        HierarchyDataObject hierarchyDataObject = new HierarchyDataObject
                        {
                            HierarchyDataId = entity.HierarchyDataId,
                            HierarchyType = entity.HierarchyType,
                            Code = entity.Code,
                            Name = entity.Name,
                            Description = entity.Description,
                            ParentHierarchyDataId = entity.ParentHierarchyDataId,
                            CreatedBy = entity.CreatedBy,
                            CreatedDate = entity.CreatedDate,
                            ExtensionDataTypeId = entity.ExtensionDataTypeId,
                            LastUpdatedBy = entity.LastUpdatedBy,
                            LastUpdatedDate = entity.LastUpdatedDate
                        };

                        hierarchyDataObject.ParseExtensionPropertiesFrom(entity);
                        results.Add(hierarchyDataObject);
                    }

                    // only cache the business objects with UTC datetime
                    base.AddCache(hierarchyType, results);
                }
            }

            // get the deep copy of the list so that the timezone change doesn't impact the cached copy.
            results = results.Clone();

            // convert UTC datetime into client timezone.
            results.ForEach(h =>
                {
                    h.CreatedDate = LocalizationUtility.ConvertUtcTimeToClientTime(h.CreatedDate);
                    h.LastUpdatedDate = LocalizationUtility.ConvertUtcTimeToClientTime(h.LastUpdatedDate);
                });

            return results;
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Initialises a new instance of <see cref="ExternalFileServerSecurity"/>.
 /// </summary>
 public ExternalFileServerSecurity()
 {
     Type         = "External File-based";
     Files        = new CloneableList <ExternalFileBase>();
     AuditLoggers = new List <SecurityLogger>();
 }