Example #1
0
        public override void RunCommand()
        {
            string current;
            EmulatorServiceType emulatorServiceType = EmulatorServiceType.None;

            List <string> .Enumerator enumerator = base.Positionals.GetEnumerator();
            try
            {
                while (true)
                {
                    if (enumerator.MoveNext())
                    {
                        current = enumerator.Current;
                        string lowerInvariant = current.ToLowerInvariant();
                        string str            = lowerInvariant;
                        if (lowerInvariant == null)
                        {
                            break;
                        }
                        if (str == "blob")
                        {
                            emulatorServiceType |= EmulatorServiceType.Blob;
                        }
                        else if (str == "queue")
                        {
                            emulatorServiceType |= EmulatorServiceType.Queue;
                        }
                        else if (str == "table")
                        {
                            emulatorServiceType |= EmulatorServiceType.Table;
                        }
                        else if (str == "all")
                        {
                            emulatorServiceType |= EmulatorServiceType.All;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        EmulatorInstance.CommonInstance.ClearData(emulatorServiceType);
                        Console.WriteLine(Resource.SuccessClearFormat, emulatorServiceType);
                        return;
                    }
                }
                throw new EmulatorException(EmulatorErrorCode.CommandLineParsingFailed, string.Format("Unexpected argument to clear command: {0}", current));
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            EmulatorInstance.CommonInstance.ClearData(emulatorServiceType);
            Console.WriteLine(Resource.SuccessClearFormat, emulatorServiceType);
        }
Example #2
0
        public void ClearData(EmulatorServiceType serviceType)
        {
            StorageContext storageContext = new StorageContext();

            storageContext.InitializeLogger();
            if ((serviceType & EmulatorServiceType.Blob) == EmulatorServiceType.Blob)
            {
                storageContext.CleanBlobData();
            }
            if ((serviceType & EmulatorServiceType.Queue) == EmulatorServiceType.Queue)
            {
                storageContext.CleanQueueData();
            }
            if ((serviceType & EmulatorServiceType.Table) == EmulatorServiceType.Table)
            {
                storageContext.CleanTableData();
            }
        }