Ejemplo n.º 1
0
        static bool Crawl(Type type)
        {
            foreach (var member in type.GetEffectiveProperties())
            {
                var memberType = GetDefinableType(member.GetPropertyOrFieldType());
                if (memberType == null || All.Contains(memberType))
                {
                    continue;
                }

                if (memberType.IsEnum)
                {
                    if (Enums.Lacks(memberType))
                    {
                        Enums.Add(memberType);
                    }
                }
                else
                {
                    All.Add(memberType);
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
 public void Add(SecurityContextSet set)
 {
     foreach (SecurityContext c in set)
     {
         All.Add(c);
     }
 }
Ejemplo n.º 3
0
        public void Load()
        {
            LoadSuccess = false;
            All.Clear();
            var filename = Config.GetVariableFilePath();

            if (!File.Exists(filename))
            {
                if (Config.IsAdministrator)
                {
                    LoadSuccess = true;
                    return;
                }
                LoadFailedMessage = $"The file {filename} does not exist.";
                return;
            }
            var dom = new XmlDocument();

            dom.Load(filename);
            var doc          = dom.DocumentElement;
            var variablesXml = doc?.SelectNodes("variable");

            if (variablesXml == null)
            {
                return;
            }
            foreach (XmlElement variableXml in variablesXml)
            {
                var name  = variableXml.GetChildString("name");
                var value = variableXml.GetChildString("value");
                All.Add(new Variable(name, value));
            }
            LoadSuccess = true;
        }
Ejemplo n.º 4
0
 public void LinesToEmployees(List <string> lines)
 {
     foreach (var line in lines)
     {
         var splitLine = line.Split(",");
         var name      = splitLine[0];
         for (var j = 1; j < splitLine.Length; j++)
         {
             splitLine[j] = splitLine[j].Trim();
         }
         var pay               = splitLine[1];
         var newPay            = splitLine[2];
         var workPercentage    = splitLine[3];
         var newWorkPercentage = splitLine[4];
         var startYear         = splitLine[5];
         var quitYear          = splitLine[6];
         var department        = splitLine[7];
         var team              = splitLine[8];
         var newTeam           = splitLine[9];
         All.Add(new Employee(
                     name,
                     pay,
                     newPay,
                     workPercentage,
                     newWorkPercentage,
                     startYear,
                     quitYear,
                     department,
                     team,
                     newTeam));
     }
 }
Ejemplo n.º 5
0
 public virtual void ReassignToWorld()
 {
     lock (All)
         All.Add(this);
     lock (this.World.Objects)
         this.World.Objects.Add(this);
 }
Ejemplo n.º 6
0
        public static void Add(Entry e)
        {
            lock (All) All.Add(e);

            var dir  = Path.GetDirectoryName(e.Path);
            var name = Path.GetFileName(e.Path);

            if (!Directory.Exists(dir))
            {
                throw new DirectoryNotFoundException("Watch.FileLines: Directory not found: " + dir);
            }
            if (!File.Exists(e.Path))
            {
                throw new FileNotFoundException("Watch.FileLines: File not found: " + e.Path, e.Path);
            }

            if (e.Watch)
            {
                var fsw = new FileSystemWatcher(dir, name)
                {
                    IncludeSubdirectories = false,
                    NotifyFilter          = NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.FileName,
                };
                fsw.Created            += delegate { lock (e.Mutex) { e.LastMeta = FileMetaSnapshot.From(e.Path); Refresh(e); } };
                fsw.Changed            += delegate { lock (e.Mutex) { e.LastMeta = FileMetaSnapshot.From(e.Path); Refresh(e); } };
                fsw.Error              += delegate { lock (e.Mutex) { e.LastMeta = FileMetaSnapshot.From(e.Path); Refresh(e); } };
                fsw.Deleted            += delegate { lock (e.Mutex) { e.LastMeta = FileMetaSnapshot.From(e.Path); Refresh(e); } };
                fsw.Renamed            += delegate { lock (e.Mutex) { e.LastMeta = FileMetaSnapshot.From(e.Path); Refresh(e); } };
                fsw.EnableRaisingEvents = true;
            }

            Refresh(e);
        }
Ejemplo n.º 7
0
        private static void Add(Actor actor, float time)
        {
            if (All.Contains(actor))
            {
                return;
            }

            All.Add(actor);
            actor._time += time; // (+=) => (=) ?
            actor.OnAdd();

            var character = actor as Character;

            if (character == null)
            {
                return;
            }

            var ch = character;

            _characters[ch.pos] = ch;
            foreach (var buff in ch.Buffs())
            {
                All.Add(buff);
                buff.OnAdd();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Write to the Event Stream
        /// </summary>
        /// <remarks>
        /// If the event stream doesn't exist, create it.
        /// The data in the event parameter includes the original stream, the recorded event, and messageId.
        /// <seealso cref="EventWritten"/>
        /// Generate the name from the event type passed in the original stream. <see cref="GetOrCreateEventTypeStream"/>
        /// The caller sets up the Event Stream, append the events."/>
        /// </remarks>
        /// <param name="event">Event to be written to the event stream</param>
        private void WriteToByEventProjection(EventWritten @event)
        {
            if (!_connected || _disposed)
            {
                throw new Exception();
            }
            if (@event.ProjectedEvent)
            {
                return;
            }
            var stream     = GetOrCreateEventTypeStream(@event, out var streamName);
            var epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            var created    = DateTime.UtcNow;
            var epochTime  = (long)(created - epochStart).TotalSeconds;

            var projectedEvent = new ProjectedEvent(
                streamName,
                @event.Event.EventNumber,
                @event.Event.EventStreamId,
                @event.Event.EventId, // reusing since the projection is linking to the original event
                stream.Count,
                @event.Event.EventType,
                @event.Event.Data,
                @event.Event.Metadata,
                @event.Event.IsJson,
                created,
                epochTime);

            stream.Add(projectedEvent);
            All.Add(projectedEvent);
            _inboundEventHandler.Handle(new EventWritten(streamName, projectedEvent, true, projectedEvent.EventNumber));
        }
Ejemplo n.º 9
0
        public EnergyIntensityConverter()
        {
            var eifd = new EnergyIntensityForDisplay(EnergyIntensityType.EnergyIntensive,
                                                     "Energy Intensive");

            All.Add(eifd);
            ForHouseholds.Add(eifd);
            eifd = new EnergyIntensityForDisplay(EnergyIntensityType.EnergySaving,
                                                 "Energy Saving");
            All.Add(eifd);
            ForHouseholds.Add(eifd);
            eifd = new EnergyIntensityForDisplay(EnergyIntensityType.Random,
                                                 "Randomly chosen devices");
            All.Add(eifd);
            ForHouseholds.Add(eifd);
            eifd = new EnergyIntensityForDisplay(EnergyIntensityType.AsOriginal,
                                                 "As chosen for the household");
            All.Add(eifd);
            eifd = new EnergyIntensityForDisplay(EnergyIntensityType.EnergyIntensivePreferMeasured,
                                                 "Energy Intensive, but prefer measured devices if available");
            All.Add(eifd);
            ForHouseholds.Add(eifd);
            eifd = new EnergyIntensityForDisplay(EnergyIntensityType.EnergySavingPreferMeasured,
                                                 "Energy Saving, but prefer measured devices if available");
            All.Add(eifd);
            ForHouseholds.Add(eifd);
        }
Ejemplo n.º 10
0
        public void SetData(string name, Dictionary <ChannelInfo, TimeSeriesDouble> data)
        {
            Name = name;

            All.Clear();
            SelectedSites.Clear();

            foreach (var d in data)
            {
                var e = All.FirstOrDefault(a => a.Name == d.Key.Name);
                if (e == null)
                {
                    e = new SiteData {
                        Name = d.Key.Name
                    };
                    All.Add(e);
                }
                switch (d.Key.Component)
                {
                case FieldComponent.Unckown:
                    throw new Exception("неизвестная компонента");

                case FieldComponent.Gic:
                    e.Gic.Ts = d.Value;
                    break;

                case FieldComponent.Ex:
                    e.Ex.Ts = d.Value;
                    break;

                case FieldComponent.Ey:
                    e.Ey.Ts = d.Value;
                    break;

                case FieldComponent.Hx:
                    e.Hx.Ts = d.Value;
                    break;

                case FieldComponent.Hy:
                    e.Hy.Ts = d.Value;
                    break;

                case FieldComponent.Hz:
                    e.Hz.Ts = d.Value;
                    break;

                case FieldComponent.Dx:
                    e.Dhx.Ts = d.Value;
                    break;

                case FieldComponent.Dy:
                    e.Dhy.Ts = d.Value;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Ejemplo n.º 11
0
        public FeedbackModel AddFeedback(Guid?userId, int?rating, string text, DateTime creationTime)
        {
            var feedback = new FeedbackModel(Guid.NewGuid(), userId, rating, text, creationTime);

            All.Add(feedback);

            return(feedback);
        }
Ejemplo n.º 12
0
        public static DbAuthor FillBlanks(Gender gender)
        {
            var p = NewPerson.FillBlanks(gender);
            var b = new DbAuthor(p.First, p.Last, p.Patronimic, (eWriterType)NewValue.Int(2));

            All.Add(b);
            return(b);
        }
Ejemplo n.º 13
0
 public Allies(int index, MemLoc primaryStatus, MemLoc secondaryStatus, params string[] words)
 {
     Index           = index;
     PrimaryStatus   = primaryStatus;
     SecondaryStatus = secondaryStatus;
     Words           = words ?? new string[0];
     All.Add(this);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Adds a CVar object to the variable list.
        /// </summary>
        /// <param name="variable">The CVar object to add</param>
        public void Set(CVar variable)
        {
            // First of all remove any old variable with the same name
            Remove(variable.Name);

            // Then add the new one
            All.Add(variable);
        }
Ejemplo n.º 15
0
 static void InitializeEnumerator()
 {
     All.Add(Idle);
     All.Add(IdleOvercovered);
     All.Add(ShipIdle);
     All.Add(ShipAttacked);
     All.Add(ShipOvercovered);
 }
Ejemplo n.º 16
0
        public CourseVisitModel AddCourseVisit(Guid courseId, Guid profileId, DateTime visitTime)
        {
            var courseVisit = new CourseVisitModel(Guid.NewGuid(), courseId, profileId, visitTime);

            All.Add(courseVisit);

            return(courseVisit);
        }
Ejemplo n.º 17
0
        public ProfileModel AddProfile(string email, string firstName, string familyName, string url, string hashedPassword, byte[] salt, string profilePictureSrc, DateTime creationTime, bool isConfirmed, AuthenticationLevel authenticationLevel, Guid?homeFacultyId)
        {
            var profile = new ProfileModel(Guid.NewGuid(), email, firstName, familyName, url, hashedPassword, salt, profilePictureSrc, creationTime, isConfirmed, authenticationLevel, homeFacultyId);

            All.Add(profile);

            return(profile);
        }
Ejemplo n.º 18
0
        public T AddVariable <T>() where T : Variable
        {
            var variable = (T)Activator.CreateInstance(typeof(T), GetNextVariableName(typeof(T).ToString().Split('.').Last()));

            variable.Owner = this;
            All.Add(variable);
            return(variable);
        }
Ejemplo n.º 19
0
 public void Add(Zone zone)
 {
     All.Add(zone);
     if (ReferenceEquals(zone.Main, zone))
     {
         Main.Add(zone);
     }
 }
        public PostFileDownloadModel AddPostFileDownload(Guid loginTokenId, Guid fileDownloadedId, DateTime downloadTime)
        {
            var postFileDownload = new PostFileDownloadModel(Guid.NewGuid(), loginTokenId, fileDownloadedId, downloadTime);

            All.Add(postFileDownload);

            return(postFileDownload);
        }
Ejemplo n.º 21
0
        private Direction(string name, int difX, int difY, int difZ)
        {
            this.Name = name;
            this.DifX = difX;
            this.DifY = difY;
            this.DifZ = difZ;

            All.Add(this);
        }
Ejemplo n.º 22
0
 public Unit Register(TypeDef type)
 {
     All        = All.Add(type.Name, type);
     AllInOrder = (from x in All.Values
                   orderby x.Order descending
                   select x)
                  .Freeze();
     return(unit);
 }
Ejemplo n.º 23
0
        public void DatagramReceived(Connection sourceConnection, byte[] datagram, DateTime receivedTime)
        {
            NumReceived++;
            LastDatagram         = datagram;
            LastConnection       = sourceConnection;
            LastReceivedDateTime = receivedTime;

            All.Add(new Tuple <byte[], Connection, DateTime>(datagram, sourceConnection, receivedTime));
        }
        public JsonResult Create(CardModel model)
        {
            int lastID = All.Select(m => m.ID).Max();

            model.ID = lastID + 1;
            All.Add(model);

            return(Json(model));
        }
Ejemplo n.º 25
0
 public TypeDef Register(TypeDef type)
 {
     All        = All.Add(type.Name, type);
     AllInOrder = (from x in All.Values
                   orderby x.Order descending
                   select x)
                  .ToSeq()
                  .Strict();
     return(type);
 }
Ejemplo n.º 26
0
 public RobotSystemLoc()
 {
     All.Add(MechanicalZero);
     //All.Add(WorkSpaceZero);
     //All.Add(PostRunParkLoc);
     All.Add(PurgeLoc);
     All.Add(ScaleLoc);
     All.Add(PrimeLoc);
     All.Add(ScrapeLoc);
 }
Ejemplo n.º 27
0
        public UniversityModel AddUniversity(string fullName, string shortName, string url)
        {
            var university = new UniversityModel(Guid.NewGuid(), fullName, shortName, url);

            All.Add(university);

            SaveChanges();

            return(university);
        }
        public NewPasswordSecretModel AddNewPasswordSecret(Guid profileId, Guid secret, DateTime creationTime, DateTime expirationTime)
        {
            var newPasswordSecretModel = new NewPasswordSecretModel(Guid.NewGuid(), profileId, secret, creationTime, expirationTime, true);

            All.Add(newPasswordSecretModel);

            SaveChanges();

            return(newPasswordSecretModel);
        }
Ejemplo n.º 29
0
 public void MakeDepartments(Employees employees)
 {
     foreach (var employee in employees.All.Where(employee => !All.Exists(d => employee.Department.Equals(d.Name))))
     {
         var department = new Department(employee.Department);
         var allEmployeesInDepartment = employees.All.Where(e => e.Department == employee.Department);
         department.Teams.MakeTeams(allEmployeesInDepartment.ToList(), department);
         All.Add(department);
     }
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Registers a new metric with the specified <paramref name="name"/> and returns the created metric. If a metric
 /// with the specified name already exists, the existing metric will be returned instead.
 /// </summary>
 /// <param name="name">The name of the metric.</param>
 /// <param name="groupName">The group name of the metric.</param>
 /// <param name="obsolete">Whether the metric is obsolete.</param>
 public static AnalyticsMetric Register(string name, string groupName, bool obsolete)
 {
     if (All.TryGetValue(name, out var metric))
     {
         return(metric);
     }
     metric = new AnalyticsMetric(name, groupName, obsolete);
     All.Add(metric.Name, metric);
     return(metric);
 }