Пример #1
0
 static void Main(string[] args)
 {
     Enumerator en = new Enumerator();
     EnumWindowsProc ewc = new EnumWindowsProc(en.VisitWindow);
     WindowsAPIWrapper.EnumWindows(ewc, (IntPtr)0);
     Console.ReadKey();
 }
Пример #2
0
		public void Initialize(IFactory factory)
		{
			this.Boolean = factory.Create<bool>();
			this.Integer = factory.Create<int>();
			this.Float = factory.Create<float>();
			this.Enumerator = factory.Create<Enumerator>();
			this.String = factory.Create<string>();
		}
Пример #3
0
 public void Enumerator()
 {
     int[] localData = new int[4] { 3, 7, 5, 8 };
     Vector<int> vector = new Vector<int>(localData);
     Enumerator<int> enumerator = new Enumerator<int>(vector);
     enumerator.MoveNext();
     object objCurrent = enumerator.Current;
     enumerator.MoveNext();
     enumerator.MoveNext();
     Assert.AreEqual(true, enumerator.MoveNext());
     object newObj = enumerator.Current;
     Assert.AreEqual(3, objCurrent);
 }
Пример #4
0
			// ICloneable

			public object Clone ()
			{
				Enumerator e = new Enumerator (host, mode);
				e.stamp = stamp;
				e.pos = pos;
				e.size = size;
				e.currentKey = currentKey;
				e.currentValue = currentValue;
				e.invalid = invalid;
				return e;
			}
Пример #5
0
 public ValueEnumerator(ModelStateDictionary dictionary, string prefix)
 {
     _prefixEnumerator = new Enumerator(dictionary, prefix);
     Current           = null;
 }
Пример #6
0
		private void  CopyToArray (Array arr, int i,
					   EnumeratorMode mode)
		{
			IEnumerator it = new Enumerator (this, mode);

			while (it.MoveNext ()) {
				arr.SetValue (it.Current, i++);
			}
		}
Пример #7
0
 public ValueEnumerator(Enumerator aEnumerator)
 {
     m_Enumerator = aEnumerator;
 }
Пример #8
0
 public void Dispose()
 {
     m_Node       = null;
     m_Enumerator = new Enumerator();
 }
Пример #9
0
 public override IEnumerator <T> GetEnumerator() => Enumerator.Empty <T>();
Пример #10
0
 public bool MoveNext()
 {
     return(Enumerator.MoveNext());
 }
Пример #11
0
 public ShimEnumerator(MonoDictionary <TKey, TValue> host)
 {
     host_enumerator = host.GetEnumerator();
 }
Пример #12
0
 /// <param name="parent">The object where the coroutine is run.</param>
 /// <param name="enumerator">The enumerator run by this manager</param>
 public CoroutineManager(MonoBehaviour parent, Enumerator enumerator)
     : this(parent)
 {
     baseEnumerator = enumerator;
 }
Пример #13
0
 public NotificationClient()
 {
     Enumerator.RegisterEndpointNotificationCallback(this);
 }
Пример #14
0
 public IEnumerator <object> GetEnumerator() => Enumerator.Create(this);
Пример #15
0
 protected virtual void OnDisposing()
 {
     Enumerator.UnregisterEndpointNotificationCallback(this);
 }
Пример #16
0
 public void  Dispose()
 {
     Enumerator.Dispose();
 }
Пример #17
0
 public ValueTask <bool> MoveNextAsync()
 {
     return(new ValueTask <bool>(Task.FromResult(Enumerator.MoveNext())));
 }
Пример #18
0
 public TestReadWrite()
 {
     CH341registry = Enumerator.Enumerate().First();
 }
Пример #19
0
 public void Dispose()
 {
     Enumerator.Dispose();
     List.Disposed = true;
 }
Пример #20
0
        private void TreeQuickSort(ref uint start, ref uint count, Enumerator e, Comparison <T> comp)
        {
            // This is more difficult than a standard quicksort because we must
            // avoid the O(log N) indexer, and use a minimal number of Enumerators
            // because building or cloning one also takes O(log N) time.
            uint offset1 = 0;
            T    pivot1  = e.Current;

            {                   // Start by choosing a pivot based the median of three
                                // values. Two candidates are random, and one is the first element.
                uint offset0 = (uint)_r.Next((int)count - 2) + 1;
                uint offset2 = (uint)_r.Next((int)count - 1) + 1;
                T    pivot0  = _root[start + offset0];
                T    pivot2  = _root[start + offset2];
                if (comp(pivot0, pivot1) > 0)
                {
                    G.Swap(ref pivot0, ref pivot1);
                    G.Swap(ref offset0, ref offset1);
                }
                if (comp(pivot1, pivot2) > 0)
                {
                    pivot1  = pivot2;
                    offset1 = offset2;
                    if (comp(pivot0, pivot1) > 0)
                    {
                        pivot1  = pivot0;
                        offset1 = offset0;
                    }
                }
            }

            var eBegin = new Enumerator(e);
            var eOut   = new Enumerator(e);

            if (offset1 != 0)
            {
                // Swap the pivot to the beginning of the range
                _root.SetAt(start + offset1, eBegin.Current, _observer);
                eBegin.LLSetCurrent(pivot1);
            }

            e.MoveNext();

            T    temp;
            bool swapEqual = true;

            // Quick sort pass
            do
            {
                int order = comp(e.Current, pivot1);
                // Swap *e and *eOut if e.Current is less than pivot. Note: in
                // case the list contains many duplicate values, we want the
                // size of the two partitions to be nearly equal. To that end,
                // we alternately swap or don't swap values that are equal to
                // the pivot, and we stop swapping in the right half.
                if (order < 0 || (order == 0 && (eOut.LastIndex - eOut._currentIndex) > (count >> 1) && (swapEqual = !swapEqual)))
                {
                    Verify(eOut.MoveNext());
                    temp = e.Current;
                    e.LLSetCurrent(eOut.Current);
                    eOut.LLSetCurrent(temp);
                }
            } while (e.MoveNext());

            // Finally, put the pivot element in the middle (at *eOut)
            temp = eBegin.Current;
            eBegin.LLSetCurrent(eOut.Current);
            eOut.LLSetCurrent(temp);

            // Now we need to sort the left and right sub-partitions. Use a
            // recursive call only to sort the smaller partition, in order to
            // guarantee O(log N) stack space usage.
            uint rightSize = eOut.LastIndex - eOut._currentIndex - 1;
            uint leftSize  = eOut._currentIndex - eBegin._currentIndex;

            Debug.Assert(leftSize + rightSize + 1 == count);
            if (rightSize > (count >> 1))
            {
                // Recursively sort the left partition; iteratively sort the right
                TreeSort(start, leftSize, comp);
                start += leftSize + 1;
                count  = rightSize;
            }
            else
            {
                // Recursively sort the right partition; iteratively sort the left
                TreeSort(start + leftSize + 1, rightSize, comp);
                count = leftSize;
            }
        }
Пример #21
0
 public bool MoveNext() => Enumerator.MoveNext();
 public SQLObjectReader(DataSet selectResult, SetterDelegate setter)
 {
     m_selectResult  = selectResult;
     m_setter        = setter;
     this.enumerator = new Enumerator(selectResult, setter);
 }
Пример #23
0
 public Enumerator GetEnumerator()
 {
     if (enumerator == null)
         enumerator = new Enumerator(Owner, Offest, Length);
     return enumerator;
 }
Пример #24
0
        private IEnumerable <Message> ToSecurityUpdateMessage(string value)
        {
            var parts = value.SplitByComma();

            var index = 0;

            var secCode    = parts[index++];
            var exchangeId = int.Parse(parts[index++], NumberStyles.HexNumber);
            var tradeBoard = parts[index++].To <int?>();
            var bidBoard   = parts[index++].To <int?>();
            var askBoard   = parts[index++].To <int?>();

            var l1Messages = new[] { exchangeId, tradeBoard, bidBoard, askBoard }
            .Where(id => id != null)
            .Select(id => id.Value)
            .Distinct()
            .ToDictionary(boardId => boardId, boardId => new Level1ChangeMessage
            {
                SecurityId = CreateSecurityId(secCode, boardId)
            });

            DateTime?lastTradeDate   = null;
            TimeSpan?lastTradeTime   = null;
            decimal? lastTradePrice  = null;
            decimal? lastTradeVolume = null;
            long?    lastTradeId     = null;

            var types = new HashSet <Level1Fields>(Enumerator.GetValues <Level1Fields>());
            var messageContentsIndex = Level1Columns.IndexOf(Level1ColumnRegistry.MessageContents);

            if (messageContentsIndex != -1)
            {
                types.Exclude(parts[messageContentsIndex + index]);
            }

            if (tradeBoard == null)
            {
                types.Remove(Level1Fields.LastTradeId);
                types.Remove(Level1Fields.LastTradeTime);
                types.Remove(Level1Fields.LastTradePrice);
                types.Remove(Level1Fields.LastTradeVolume);
            }

            if (bidBoard == null)
            {
                types.Remove(Level1Fields.BestBidTime);
                types.Remove(Level1Fields.BestBidPrice);
                types.Remove(Level1Fields.BestBidVolume);
            }

            if (askBoard == null)
            {
                types.Remove(Level1Fields.BestAskTime);
                types.Remove(Level1Fields.BestAskPrice);
                types.Remove(Level1Fields.BestAskVolume);
            }

            foreach (var column in Level1Columns)
            {
                var colValue = parts[index++];

                if (colValue.IsEmpty())
                {
                    continue;
                }

                //colValue = colValue.To(column.Type);

                switch (column.Field)
                {
                case IQFeedLevel1Column.DefaultField:
                {
                    var typedColValue = column.Convert(colValue);

                    if (typedColValue != null)
                    {
                        l1Messages[exchangeId].AddValue(column.Name, typedColValue);
                    }

                    break;
                }

                case Level1Fields.LastTradeId:
                    if (types.Contains(column.Field))
                    {
                        lastTradeId = colValue.To <long?>();

                        if (lastTradeId != null && lastTradeId != 0)
                        {
                            l1Messages[tradeBoard.Value].Add(column.Field, lastTradeId.Value);
                        }
                    }
                    break;

                case Level1Fields.LastTradeTime:
                    if (types.Contains(column.Field))
                    {
                        if (column == Level1ColumnRegistry.LastDate)
                        {
                            lastTradeDate = colValue.TryToDateTime(column.Format);
                        }
                        else if (column == Level1ColumnRegistry.LastTradeTime)
                        {
                            lastTradeTime = column.ConvertToTimeSpan(colValue);
                        }

                        if (lastTradeDate.HasValue && lastTradeTime.HasValue)
                        {
                            var l1Msg = l1Messages[tradeBoard.Value];
                            l1Msg.ServerTime = (lastTradeDate.Value + lastTradeTime.Value).ApplyTimeZone(TimeHelper.Est);
                            l1Msg.Add(Level1Fields.LastTradeTime, l1Msg.ServerTime);
                        }
                    }
                    break;

                case Level1Fields.LastTradePrice:
                case Level1Fields.LastTradeVolume:
                    if (types.Contains(column.Field))
                    {
                        var decValue = colValue.To <decimal?>();

                        l1Messages[tradeBoard.Value].TryAdd(column.Field, decValue);

                        if (column == Level1ColumnRegistry.LastTradePrice)
                        {
                            lastTradePrice = decValue;
                        }
                        else                                // if (column == SessionHolder.Level1ColumnRegistry.LastTradeVolume)
                        {
                            lastTradeVolume = decValue;
                        }
                    }
                    break;

                case Level1Fields.BestBidTime:
                    if (types.Contains(column.Field))
                    {
                        var typedColValue = column.ConvertToTimeSpan(colValue);

                        if (typedColValue != null)
                        {
                            var l1Msg = l1Messages[bidBoard.Value];
                            l1Msg.ServerTime = (DateTime.Today + typedColValue.Value).ApplyTimeZone(TimeHelper.Est);
                            l1Msg.Add(Level1Fields.BestBidTime, l1Msg.ServerTime);
                        }
                    }
                    break;

                case Level1Fields.BestBidPrice:
                case Level1Fields.BestBidVolume:
                    if (types.Contains(column.Field))
                    {
                        l1Messages[bidBoard.Value].TryAdd(column.Field, colValue.To <decimal?>());
                    }
                    break;

                case Level1Fields.BestAskTime:
                    if (types.Contains(column.Field))
                    {
                        var typedColValue = column.ConvertToTimeSpan(colValue);

                        if (typedColValue != null)
                        {
                            var l1Msg = l1Messages[askBoard.Value];
                            l1Msg.ServerTime = (DateTime.Today + typedColValue.Value).ApplyTimeZone(TimeHelper.Est);
                            l1Msg.Add(Level1Fields.BestAskTime, l1Msg.ServerTime);
                        }
                    }
                    break;

                case Level1Fields.BestAskPrice:
                case Level1Fields.BestAskVolume:
                    if (types.Contains(column.Field))
                    {
                        l1Messages[askBoard.Value].TryAdd(column.Field, colValue.To <decimal?>());
                    }
                    break;

                case Level1Fields.OpenInterest:
                case Level1Fields.OpenPrice:
                case Level1Fields.HighPrice:
                case Level1Fields.LowPrice:
                case Level1Fields.ClosePrice:
                case Level1Fields.SettlementPrice:
                case Level1Fields.VWAP:
                    if (types.Contains(column.Field))
                    {
                        l1Messages[exchangeId].TryAdd(column.Field, colValue.To <decimal?>());
                    }
                    break;

                default:
                    if (types.Contains(column.Field))
                    {
                        var typedColValue = column.Convert(colValue);

                        if (typedColValue != null)
                        {
                            l1Messages[exchangeId].Add(column.Field, typedColValue);
                        }
                    }
                    break;
                }
            }

            foreach (var l1Msg in l1Messages.Values)
            {
                if (l1Msg.Changes.Count <= 0)
                {
                    continue;
                }

                yield return(new SecurityMessage {
                    SecurityId = l1Msg.SecurityId
                });

                if (l1Msg.ServerTime.IsDefault())
                {
                    l1Msg.ServerTime = CurrentTime.Convert(TimeHelper.Est);
                }

                yield return(l1Msg);
            }

            if (!types.Contains(Level1Fields.LastTrade) || !lastTradeDate.HasValue || !lastTradeTime.HasValue ||
                !lastTradeId.HasValue || !lastTradePrice.HasValue || !lastTradeVolume.HasValue)
            {
                yield break;
            }

            yield return(new ExecutionMessage
            {
                SecurityId = l1Messages[tradeBoard.Value].SecurityId,
                TradeId = lastTradeId.Value,
                ServerTime = (lastTradeDate.Value + lastTradeTime.Value).ApplyTimeZone(TimeHelper.Est),
                TradePrice = lastTradePrice.Value,
                TradeVolume = lastTradeVolume.Value,
                ExecutionType = ExecutionTypes.Tick,
            });
        }
Пример #25
0
        private void LoadFormInfo()
        {
            try
            {
                halconHelper = new HalconHelper(hWindowControl1.HalconWindow);
                List <IDeviceInfo> li = Enumerator.EnumerateDevices();
                //if (Convert.ToInt32(this.Tag) != -1)
                if (li.Count > 0)
                {
                    m_dev = Enumerator.GetDeviceByIndex(0);
                    //m_dev = Enumerator.GetDeviceByIndex(Convert.ToInt32(this.Tag));
                    // 注册链接时间

                    m_dev.CameraOpened   += OnCameraOpen;
                    m_dev.ConnectionLost += OnConnectLoss;
                    m_dev.CameraClosed   += OnCameraClose;
                    // 打开设备
                    if (!m_dev.Open())
                    {
                        MessageBox.Show(@"连接相机失败");
                        return;
                    }

                    // 关闭Trigger
                    //m_dev.TriggerSet.Close();
                    // 打开Software Trigger
                    m_dev.TriggerSet.Open(TriggerSourceEnum.Software);
                    // 设置图像格式
                    using (IEnumParameter p = m_dev.ParameterCollection[ParametrizeNameSet.ImagePixelFormat])
                    {
                        p.SetValue("Mono8");
                    }

                    // 注册码流回调事件
                    m_dev.StreamGrabber.ImageGrabbed += OnImageGrabbed;

                    // 开启码流
                    if (!m_dev.GrabUsingGrabLoopThread())
                    {
                        MessageBox.Show(@"开启码流失败");
                        return;
                    }
                    else
                    {
                        m_dev.ExecuteSoftwareTrigger();
                    }
                }
                else
                {
                }
                //注册一维码识别完成事件
                halconHelper.Complete += OnComplete;
                halconHelper.Error    += OnError;
                //注册串口接收事件
                serialComm.DateReceived += new Comm.EventHandle(OnDataReceived);
                weightComm.DateReceived += new Comm.EventHandle(OnWeightDataReceived);
            }
            catch (Exception ex)
            {
                Catcher.Show(ex);
            }
        }
Пример #26
0
 public KeyEnumerator(Enumerator aEnumerator)
 {
     m_Enumerator = aEnumerator;
 }
Пример #27
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public virtual bool MoveNext()
 {
     if (_atStart)
         return true;
     if (_subcollectionEnumerator != null)
     {
         if (_subcollectionEnumerator.MoveNext())
             return true;
         _subcollectionEnumerator = null;
     }
     if (_index >= _max)
         return false;
     return true;
 }
Пример #28
0
 public void Reset() => Enumerator.Reset();
Пример #29
0
        //private int[] array = new int[10];
        public IEnumerator GetEnumerator()
        {
            Enumerator enumerator = new Enumerator(0);

            return(enumerator);
        }
Пример #30
0
            public void Set(string value)
            {
                Owner.Owner.StartRecordHystory();
                Owner.Remove(Offest, Length);
                if (!string.IsNullOrEmpty(value))
                    Owner.Write(value, Offest);
                Owner.Owner.CommitHystory();

                Length = value.Length;
                End = Offest + Length;
                enumerator = null;
            }
Пример #31
0
 public IColorEnumerator GetEnumerator()
 {
     if (list == null) 
         list = new Enumerator(this);
     return list;
 }
Пример #32
0
    public static Int32 Parse(List<Token> src, Int32 begin, out Enumerator enumerator)
    {
        return Parser.ParseSequence(src, begin, out enumerator,

            // enumeration
            _enumeration_constant.Parse,

            // [
            Parser.GetOptionalParser(
                null,
                Parser.GetSequenceParser(
                    // '='
                    Parser.GetOperatorParser(OperatorVal.EQ),

                    // constant_expression
                    _constant_expression.Parse,
                    (Boolean _, Expr expr) => expr
                )
            ),
            // ]?

            (String name, Expr expr) => new Enumerator(name, expr)

        );
    }
        /// <summary>
        /// It creates a new ProxyAccount or gets an existing
        /// one from JobServer and updates all properties.
        /// </summary>
        private bool CreateOrUpdateProxyAccount(
            AgentProxyInfo proxyInfo,
            bool isUpdate)
        {
            ProxyAccount proxyAccount = null;

            if (!isUpdate)
            {
                proxyAccount = new ProxyAccount(this.DataContainer.Server.JobServer,
                                                proxyInfo.AccountName,
                                                proxyInfo.CredentialName,
                                                proxyInfo.IsEnabled,
                                                proxyInfo.Description);

                UpdateProxyAccount(proxyAccount);
                proxyAccount.Create();
            }
            else if (this.DataContainer.Server.JobServer.ProxyAccounts.Contains(this.proxyAccountName))
            {
                // Try refresh and check again
                this.DataContainer.Server.JobServer.ProxyAccounts.Refresh();
                if (this.DataContainer.Server.JobServer.ProxyAccounts.Contains(this.proxyAccountName))
                {
                    // fail since account exists and asked to create a new one
                    if (!isUpdate)
                    {
                        return(false);
                    }

                    proxyAccount = AgentProxyAccount.GetProxyAccount(this.proxyAccountName, this.DataContainer.Server.JobServer);
                    // Set the other properties
                    proxyAccount.CredentialName = proxyInfo.CredentialName;
                    proxyAccount.Description    = proxyInfo.Description;

                    UpdateProxyAccount(proxyAccount);
                    proxyAccount.Alter();

                    // Rename the proxy if needed
                    // This has to be done after Alter, in order to
                    // work correcly when scripting this action.
                    if (this.proxyAccountName != proxyInfo.AccountName)
                    {
                        proxyAccount.Rename(proxyInfo.AccountName);
                    }
                }
            }
            else
            {
                return(false);
            }

            return(true);

#if false  // @TODO - reenable subsystem code below
            // Update the subsystems
            foreach (AgentSubSystem subsystem in this.addSubSystems)
            {
                proxyAccount.AddSubSystem(subsystem);
            }

            foreach (AgentSubSystem subsystem in this.removeSubSystems)
            {
                proxyAccount.RemoveSubSystem(subsystem);

                // Update jobsteps that use this proxy accunt
                // when some subsystems are removed from it
                string reassignToProxyName = this.reassignToProxyNames[(int)subsystem];

                if (reassignToProxyName != null)
                {
                    // if version is sql 11 and above call SMO API  to reassign proxy account
                    if (Utils.IsSql11OrLater(this.DataContainer.Server.ServerVersion))
                    {
                        proxyAccount.Reassign(reassignToProxyName);
                    }
                    else
                    {
                        // legacy code
                        // Get a list of all job step objects that use this proxy and this subsystem
                        Request req = new Request();
                        req.Urn = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                "Server/JobServer/Job/Step[@ProxyName=\'{0}\' and @SubSystem={1}]",
                                                Urn.EscapeString(proxyAccount.Name),
                                                (int)subsystem);
                        req.Fields = new string[] { "Name" };
                        req.ParentPropertiesRequests = new PropertiesRequest[1] {
                            new PropertiesRequest()
                        };
                        req.ParentPropertiesRequests[0].Fields = new string[] { "Name" };

                        Enumerator en    = new Enumerator();
                        DataTable  table = en.Process(this.DataContainer.ServerConnection, req);
                        foreach (DataRow row in table.Rows)
                        {
                            // Get the actual job step object using urn
                            string  urnString = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Server/JobServer/Job[@Name=\"{0}\"/Step[@Name=\"{1}\"", row["Job_Name"], row["Name"]);
                            Urn     urn       = new Urn(urnString);
                            JobStep jobStep   = (JobStep)this.DataContainer.Server.GetSmoObject(urn);

                            jobStep.ProxyName = reassignToProxyName;
                            jobStep.Alter();
                        }
                    }
                }
            }
#endif
        }
 public IEnumerator GetEnumerator()
 {
     if (this.enumerator == null)
         this.enumerator = new Enumerator (this);
     return this.enumerator;
 }
Пример #35
0
        public List <RestoreItemSource> GetLatestBackupLocations(string databaseName)
        {
            List <RestoreItemSource> latestLocations = new List <RestoreItemSource>();
            Enumerator en = null;
            DataSet    ds = new DataSet();

            ds.Locale = System.Globalization.CultureInfo.InvariantCulture;
            Request req = new Request();

            en = new Enumerator();

            req.Urn                  = "Server/BackupSet[@DatabaseName='" + Urn.EscapeString(databaseName) + "']";
            req.OrderByList          = new OrderBy[1];
            req.OrderByList[0]       = new OrderBy();
            req.OrderByList[0].Field = "BackupFinishDate";
            req.OrderByList[0].Dir   = OrderBy.Direction.Desc;

            try
            {
                ds = en.Process(this.sqlConnection, req);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string mediaSetID = Convert.ToString(ds.Tables[0].Rows[0]["MediaSetId"], System.Globalization.CultureInfo.InvariantCulture);
                    ds.Clear();
                    req     = new Request();
                    req.Urn = "Server/BackupMediaSet[@ID='" + Urn.EscapeString(mediaSetID) + "']/MediaFamily";
                    ds      = en.Process(this.sqlConnection, req);
                    int count = ds.Tables[0].Rows.Count;
                    if (count > 0)
                    {
                        for (int i = 0; i < count; i++)
                        {
                            RestoreItemSource restoreItemSource = new RestoreItemSource();
                            DeviceType        deviceType        = (DeviceType)(Convert.ToInt16(ds.Tables[0].Rows[i]["BackupDeviceType"], System.Globalization.CultureInfo.InvariantCulture));
                            string            location          = Convert.ToString(ds.Tables[0].Rows[i]["LogicalDeviceName"], System.Globalization.CultureInfo.InvariantCulture);
                            bool isLogical = (location.Length > 0);
                            if (false == isLogical)
                            {
                                location = Convert.ToString(ds.Tables[0].Rows[i]["PhysicalDeviceName"], System.Globalization.CultureInfo.InvariantCulture);
                            }
                            else
                            {
                                // We might receive the logical name as "logicaldevicename(physicalpath)"
                                // We try to get the device name out of it
                                int pos = location.IndexOf('(');
                                if (pos > 0)
                                {
                                    location = location.Substring(0, pos);
                                }
                            }
                            restoreItemSource.RestoreItemDeviceType = deviceType;
                            restoreItemSource.RestoreItemLocation   = location;
                            restoreItemSource.IsLogicalDevice       = isLogical;
                            latestLocations.Add(restoreItemSource);
                        }
                    }
                }
            }
            /// LPU doesn't have rights to enumerate msdb.backupset
            catch (Exception)
            {
            }
            return(latestLocations);
        }
Пример #36
0
		private void  CopyToArray (Array arr, int i, 
					   EnumeratorMode mode)
		{
			if (arr == null)
				throw new ArgumentNullException ("arr");

			if (i < 0 || i + this.Count > arr.Length)
				throw new ArgumentOutOfRangeException ("i");
			
			IEnumerator it = new Enumerator (this, mode);

			while (it.MoveNext ()) {
				arr.SetValue (it.Current, i++);
			}
		}
 public override bool Read()
 {
     return(Enumerator.MoveNext());
 }
Пример #38
0
        private void Erase_Click(object sender, RoutedEventArgs e)
        {
            if (_token != null)
            {
                StopSync();
                return;
            }

            var securities = (AllSecurities.IsChecked == true
                                ? EntityRegistry.Securities.Where(s => !s.IsAllSecurity())
                                : SelectSecurityBtn.SelectedSecurities
                              ).ToArray();

            var from = From.Value ?? DateTime.MinValue;
            var to   = To.Value ?? DateTime.MaxValue;

            if (from > to)
            {
                new MessageBoxBuilder()
                .Caption(LocalizedStrings.Str2879)
                .Text(LocalizedStrings.Str1119Params.Put(from, to))
                .Warning()
                .Owner(this)
                .Show();

                return;
            }

            if (securities.IsEmpty())
            {
                new MessageBoxBuilder()
                .Caption(LocalizedStrings.Str2879)
                .Text(LocalizedStrings.Str2881)
                .Warning()
                .Owner(this)
                .Show();

                return;
            }

            var msg = string.Empty;

            if (from != DateTime.MinValue || to != DateTime.MaxValue)
            {
                msg += LocalizedStrings.Str3846;

                if (from != DateTime.MinValue)
                {
                    msg += " " + LocalizedStrings.XamlStr624.ToLowerInvariant() + " " + from.ToString("yyyy-MM-dd");
                }

                if (to != DateTime.MaxValue)
                {
                    msg += " " + LocalizedStrings.XamlStr132 + " " + to.ToString("yyyy-MM-dd");
                }
            }

            //msg += AllSecurities.IsChecked == true
            //			   ? LocalizedStrings.Str2882
            //			   : LocalizedStrings.Str2883Params.Put(securities.Take(100).Select(sec => sec.Id).Join(", "));

            if (new MessageBoxBuilder()
                .Caption(LocalizedStrings.Str2879)
                .Text(LocalizedStrings.Str2884Params.Put(msg))
                .Warning()
                .YesNo()
                .Owner(this)
                .Show() != MessageBoxResult.Yes)
            {
                return;
            }

            Erase.Content = LocalizedStrings.Str2890;
            _token        = new CancellationTokenSource();

            var drives = Drive.SelectedDrive == null
                                        ? DriveCache.Instance.AllDrives.ToArray()
                                        : new[] { Drive.SelectedDrive };

            if (to != DateTime.MaxValue && to.TimeOfDay == TimeSpan.Zero)
            {
                to = to.EndOfDay();
            }

            Task.Factory.StartNew(() =>
            {
                var dataTypes = new[] { typeof(Trade), typeof(MarketDepth), typeof(Level1ChangeMessage), typeof(OrderLogItem), typeof(CandleMessage) };
                var formats   = Enumerator.GetValues <StorageFormats>().ToArray();

                var iterCount = drives.Length * securities.Length * dataTypes.Length * formats.Length;

                this.GuiSync(() => Progress.Maximum = iterCount);

                foreach (var drive in drives)
                {
                    if (_token.IsCancellationRequested)
                    {
                        break;
                    }

                    foreach (var security in securities)
                    {
                        if (_token.IsCancellationRequested)
                        {
                            break;
                        }

                        foreach (var format in formats)
                        {
                            if (_token.IsCancellationRequested)
                            {
                                break;
                            }

                            foreach (var dataType in dataTypes)
                            {
                                if (_token.IsCancellationRequested)
                                {
                                    break;
                                }

                                if (dataType == typeof(CandleMessage))
                                {
                                    foreach (var candleType in drive.GetCandleTypes(security.ToSecurityId(), format))
                                    {
                                        StorageRegistry
                                        .GetStorage(security, candleType.Item1, candleType.Item2, drive, format)
                                        .Delete(from, to);
                                    }
                                }
                                else
                                {
                                    StorageRegistry
                                    .GetStorage(security, dataType, null, drive, format)
                                    .Delete(from, to);
                                }

                                this.GuiSync(() =>
                                {
                                    Progress.Value++;
                                });
                            }
                        }
                    }
                }
            }, _token.Token)
            .ContinueWithExceptionHandling(this, res =>
            {
                Erase.Content   = LocalizedStrings.Str2060;
                Erase.IsEnabled = true;

                Progress.Value = 0;
                _token         = null;
            });
        }
Пример #39
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="result">return kind</param>
 /// <param name="invoke">internal invoke call</param>
 public EnumeratorAttribute(Enumerator result, EnumeratorInvoke invoke)
 {
     Result = result;
     Invoke = invoke;
 }