static void Main()
{
InitializeWordsByChar();
int textLinesCount = int.Parse(Console.ReadLine().ToLower());
for (int i = 0; i < textLinesCount; i++)
{
GetWords(Console.ReadLine().ToLower());
}
int wordsCount = int.Parse(Console.ReadLine());
for (int i = 0; i < wordsCount; i++)
{
string word = Console.ReadLine();
string wordLowerCase = word.ToLower();
HashSet<string> currentWords = new HashSet<string>();
currentWords.UnionWith(wordsByChar[wordLowerCase[0]]);
for (int j = 1; j < wordLowerCase.Length; j++)
{
currentWords.IntersectWith(wordsByChar[wordLowerCase[j]]);
}
Console.WriteLine("{0} -> {1}", word, currentWords.Count);
}
}
public static void ApplySetPieces(World world)
{
var map = world.Map;
int w = map.Width, h = map.Height;
Random rand = new Random();
HashSet<Rect> rects = new HashSet<Rect>();
foreach (var dat in setPieces)
{
int size = dat.Item1.Size;
int count = rand.Next(dat.Item2, dat.Item3);
for (int i = 0; i < count; i++)
{
IntPoint pt = new IntPoint();
Rect rect;
int max = 50;
do
{
pt.X = rand.Next(0, w);
pt.Y = rand.Next(0, h);
rect = new Rect() { x = pt.X, y = pt.Y, w = size, h = size };
max--;
} while ((Array.IndexOf(dat.Item4, map[pt.X, pt.Y].Terrain) == -1 ||
rects.Any(_ => Rect.Intersects(rect, _))) &&
max > 0);
if (max <= 0) continue;
dat.Item1.RenderSetPiece(world, pt);
rects.Add(rect);
}
}
}
private static IEnumerable<long> Eratostenes()
{
const int max = 2000000;
var primes = new List<long>();
var crossedOff = new HashSet<long>();
long candidate = 1;
while (candidate < max)
{
candidate++;
if (crossedOff.Contains(candidate))
{
continue;
}
primes.Add(candidate);
// remove multiples of candidate
for (var i = candidate; i < max + 1; i += candidate)
{
crossedOff.Add(i);
}
}
return primes.ToArray();
}
private void CreateRandomIndexes(int maxSegments)
{
dir = NewDirectory();
numDocs = AtLeast(150);
int numTerms = TestUtil.NextInt(Random(), 1, numDocs / 5);
ISet<string> randomTerms = new HashSet<string>();
while (randomTerms.size() < numTerms)
{
randomTerms.add(TestUtil.RandomSimpleString(Random()));
}
terms = new List<string>(randomTerms);
int seed = Random().Next();
IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(new Random(seed)));
iwc.SetMergePolicy(TestSortingMergePolicy.NewSortingMergePolicy(sort));
iw = new RandomIndexWriter(new Random(seed), dir, iwc);
for (int i = 0; i < numDocs; ++i)
{
Document doc = RandomDocument();
iw.AddDocument(doc);
if (i == numDocs / 2 || (i != numDocs - 1 && Random().nextInt(8) == 0))
{
iw.Commit();
}
if (Random().nextInt(15) == 0)
{
string term = RandomInts.RandomFrom(Random(), terms);
iw.DeleteDocuments(new Term("s", term));
}
}
reader = iw.Reader;
}
public void ModelMetadataProvider_UsesPredicateOnType()
{
// Arrange
var type = typeof(User);
var provider = CreateProvider();
var context = new ModelBindingContext();
var expected = new[] { "IsAdmin", "UserName" };
// Act
var metadata = provider.GetMetadataForType(type);
// Assert
var predicate = metadata.PropertyBindingPredicateProvider.PropertyFilter;
var matched = new HashSet<string>();
foreach (var property in metadata.Properties)
{
if (predicate(context, property.PropertyName))
{
matched.Add(property.PropertyName);
}
}
Assert.Equal<string>(expected, matched);
}
private void CollectEntities(int addr, Dictionary<int, Entity> list)
{
int num = addr;
addr = M.ReadInt(addr + 4);
var hashSet = new HashSet<int>();
var queue = new Queue<int>();
queue.Enqueue(addr);
while (queue.Count > 0)
{
int nextAddr = queue.Dequeue();
if (hashSet.Contains(nextAddr))
continue;
hashSet.Add(nextAddr);
if (M.ReadByte(nextAddr + 21) == 0 && nextAddr != num && nextAddr != 0)
{
int key = M.ReadInt(nextAddr + 12);
if (!list.ContainsKey(key))
{
int address = M.ReadInt(nextAddr + 16);
var entity = base.GetObject<Entity>(address);
list.Add(key, entity);
}
queue.Enqueue(M.ReadInt(nextAddr));
queue.Enqueue(M.ReadInt(nextAddr + 8));
}
}
}
public override void OnUpdateList ()
{
base.OnUpdateList ();
StackFrame frame = DebuggingService.CurrentFrame;
if (frame == null || !FrameEquals (frame, lastFrame)) {
tree.ClearExpressions ();
lastExpressions = null;
}
lastFrame = frame;
if (frame == null)
return;
//FIXME: tree should use the local refs rather than expressions. ATM we exclude items without names
var expr = new HashSet<string> (frame.GetAllLocals ().Select (i => i.Name)
.Where (n => !string.IsNullOrEmpty (n) && n != "?"));
//add expressions not in tree already, remove expressions that are longer valid
if (lastExpressions != null) {
foreach (string rem in lastExpressions.Except (expr))
tree.RemoveExpression (rem);
foreach (string rem in expr.Except (lastExpressions))
tree.AddExpression (rem);
} else {
tree.AddExpressions (expr);
}
lastExpressions = expr;
}
private static void SwapParameterTypes(MethodDefinition method,
TypeDefinition targetDependency,
TypeReference interfaceType,
HashSet<MethodReference> modifiedMethods)
{
if (method.IsAbstract || !method.HasBody)
return;
bool modified = false;
var parameters = method.Parameters.Cast<ParameterDefinition>();
foreach (var parameter in parameters)
{
var parameterType = parameter.ParameterType;
if (parameterType != targetDependency)
continue;
parameter.ParameterType = interfaceType;
modified = true;
}
if (!modified)
return;
modifiedMethods.Add(method);
}
internal AnalysisQueue(VsProjectAnalyzer analyzer) {
_workEvent = new AutoResetEvent(false);
_cancel = new CancellationTokenSource();
_analyzer = analyzer;
// save the analysis once it's ready, but give us a little time to be
// initialized and start processing stuff...
_lastSave = DateTime.Now - _SaveAnalysisTime + TimeSpan.FromSeconds(10);
_queue = new List<IAnalyzable>[PriorityCount];
for (int i = 0; i < PriorityCount; i++) {
_queue[i] = new List<IAnalyzable>();
}
_enqueuedGroups = new HashSet<IGroupableAnalysisProject>();
_workThread = new Thread(Worker);
_workThread.Name = "Node.js Analysis Queue";
_workThread.Priority = ThreadPriority.BelowNormal;
_workThread.IsBackground = true;
// start the thread, wait for our synchronization context to be created
using (AutoResetEvent threadStarted = new AutoResetEvent(false)) {
_workThread.Start(threadStarted);
threadStarted.WaitOne();
}
}
public static H3.Cell[] CalcCells2( Sphere[] mirrors, H3.Cell[] cells, Settings settings )
{
HashSet<Vector3D> completedCellIds = new HashSet<Vector3D>( cells.Select( c => c.ID ).ToArray() );
List<H3.Cell> completedCells = new List<H3.Cell>( cells );
ReflectCellsRecursive2( mirrors, cells, settings, completedCells, completedCellIds );
return completedCells.ToArray();
}
private void AssignConnectors(DialogueEntry entry, Conversation conversation, HashSet<string> alreadyConnected, HashSet<int> entriesVisited, int level)
{
// Sanity check to prevent infinite recursion:
if (level > 10000) return;
// Set non-connectors:
foreach (Link link in entry.outgoingLinks) {
if (link.originConversationID == link.destinationConversationID) {
string destination = string.Format("{0}.{1}", link.destinationConversationID, link.destinationDialogueID);
if (alreadyConnected.Contains(destination)) {
link.isConnector = true;
} else {
link.isConnector = false;
alreadyConnected.Add(destination);
}
}
}
// Then process each child:
foreach (Link link in entry.outgoingLinks) {
if (link.originConversationID == link.destinationConversationID) {
if (!entriesVisited.Contains(link.destinationDialogueID)) {
entriesVisited.Add(link.destinationDialogueID);
var childEntry = conversation.GetDialogueEntry(link.destinationDialogueID);
if (childEntry != null) {
AssignConnectors(childEntry, conversation, alreadyConnected, entriesVisited, level + 1);
}
}
}
}
}
public static void Write(TextWriter writer, IEnumerable<Dictionary<string, string>> records)
{
if (records == null) return; //AOT
var allKeys = new HashSet<string>();
var cachedRecords = new List<IDictionary<string, string>>();
foreach (var record in records)
{
foreach (var key in record.Keys)
{
if (!allKeys.Contains(key))
{
allKeys.Add(key);
}
}
cachedRecords.Add(record);
}
var headers = allKeys.OrderBy(key => key).ToList();
if (!CsvConfig<Dictionary<string, string>>.OmitHeaders)
{
WriteRow(writer, headers);
}
foreach (var cachedRecord in cachedRecords)
{
var fullRecord = headers.ConvertAll(header =>
cachedRecord.ContainsKey(header) ? cachedRecord[header] : null);
WriteRow(writer, fullRecord);
}
}
/// <summary>
/// Locates the changes between the prior and post state of the modules..
/// </summary>
/// <param name="modules_prior">List of the available modules prior to the update.</param>
/// <param name="modules_post">List of the available modules after the update.</param>
private void PrintChanges(List<CkanModule> modules_prior, List<CkanModule> modules_post)
{
var prior = new HashSet<CkanModule>(modules_prior, new NameComparer());
var post = new HashSet<CkanModule>(modules_post, new NameComparer());
var added = new HashSet<CkanModule>(post.Except(prior, new NameComparer()));
var removed = new HashSet<CkanModule>(prior.Except(post, new NameComparer()));
var unchanged = post.Intersect(prior);//Default compare includes versions
var updated = post.Except(unchanged).Except(added).Except(removed).ToList();
// Print the changes.
user.RaiseMessage("Found {0} new modules, {1} removed modules and {2} updated modules.", added.Count(), removed.Count(), updated.Count());
if (added.Count > 0)
{
PrintModules("New modules [Name (CKAN identifier)]:", added);
}
if (removed.Count > 0)
{
PrintModules("Removed modules [Name (CKAN identifier)]:", removed);
}
if (updated.Count > 0)
{
PrintModules("Updated modules [Name (CKAN identifier)]:", updated);
}
}
internal CoordinatorScratchpad(Type elementType)
{
_elementType = elementType;
_nestedCoordinatorScratchpads = new List<CoordinatorScratchpad>();
_expressionWithErrorHandlingMap = new Dictionary<Expression, Expression>();
_inlineDelegates = new HashSet<LambdaExpression>();
}
private IList<string> DFS(string s, HashSet<string> dict, Dictionary<string, IList<string>> map){
IList<string> matches = new List<string>();
if(s==""){ //Base Case
matches.Add("");
return matches;
}
if(map.ContainsKey(s)) //if s is already in the map, directly return its value
return map[s];
int len = s.Length;
for(int i=1;i<s.Length+1;i++){
string prev = s.Substring(0,i);
if(dict.Contains(prev)){ //if prev is in the dict
IList<string> postMatches = DFS(s.Substring(i,len-i),dict,map);
foreach(string sentence in postMatches){
if(sentence=="") //if s.Substring(i,len) is empty
matches.Add(prev);
else
matches.Add(prev+" "+sentence);
}
}
}
map.Add(s, matches); //after get all matches for s, put the entry into map.
return matches;
}
public Conversion ClassifyConversionFromExpression(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
return ClassifyConversionFromExpression(null, source, destination, ref useSiteDiagnostics);
}
/// <summary>
/// first construct a prime list up to 1k(using seive)
/// and check each number after 647 to see if it matches with criteria given by the question
/// 1. for each number, first find out all the prime factors, and add them to a hashset
/// 2. if prime factors added are not exactly 4, reset the hashset
/// 3 (start variable is used to make sure the numbers are continuous, if there is a gap between numbers, reset the hashset)
/// 4. if prime factors added are exactly 4, check the hashset count, if it is 16 return the answer
/// 5. if it is not 16, continues to next number
/// </summary>
/// <returns></returns>
static int brute_force_test_each_number_for_match()
{
var max = 1000; //randomly chose, it works :P
var bound = (int)Math.Sqrt(max);
bool[] primes = new bool[max];
primes[0] = true;
primes[1] = true;
int s, m;
for (s = 2; s <= bound; s++)
{
if (primes[s] == false)
{
for (m = s * s; m < max; m += s)
{
primes[m] = true;
}
}
}
var factor = 4;
var start = 0;
var num = 0;
var pwr = 1;
var set = new HashSet<int>();
var count = 1;
for (s = 647; s < 200000; s++)
{
num = s;
for (m = 2; m < max; m++)
{
if (primes[m] == false)
{
pwr = 1;
while (num % m == 0)
{
pwr *= m;
num /= m;
}
if (pwr != 1)
set.Add(pwr);
if (num <= 1)
break;
}
}
if (set.Count == factor * count && (s == start + 1 || start == 0))
{
if (count == factor)
return s - 3;
start = s;
count++;
}
else
{
set.Clear();
count = 1;
start = 0;
}
}
return 0;
}
public static int Solution2(Stopwatch timer)
{
timer.Restart();
var a = new HashSet<int>();
int maxlcm = 1;
int t = 0;
var results = new List<int>();
for (int i = 2; i <= 20; i++)
{
int k = i%2 == 0 ? 1 : 2;
for (int j = k; j < i; j+=2)
{
if (gcd(i, j) == 1)
{
a.Add(2*i*(i + j));
}
}
}
var sortedA = a.OrderBy(v => v).ToArray();
while (maxlcm < 1000)
{
maxlcm = lcm(maxlcm, sortedA[t]);
results.Add(maxlcm);
t++;
}
int res = results[results.Count - 2];
timer.Stop();
return res;
}
/// <remarks>
/// http://stackoverflow.com/questions/730268/unique-random-string-generation
/// </remarks>
string GenerateRandomString(int length,
string allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
{
if (length < 0) throw new ArgumentOutOfRangeException(nameof(length), "length cannot be less than zero.");
if (string.IsNullOrEmpty(allowedChars)) throw new ArgumentException("allowedChars may not be empty.");
const int byteSize = 0x100;
var allowedCharSet = new HashSet<char>(allowedChars).ToArray();
if (byteSize < allowedCharSet.Length)
throw new ArgumentException($"allowedChars may contain no more than {byteSize} characters.");
// Guid.NewGuid and System.Random are not particularly random. By using a
// cryptographically-secure random number generator, the caller is always
// protected, regardless of use.
using (var rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
{
var result = new StringBuilder();
var buf = new byte[128];
while (result.Length < length)
{
rng.GetBytes(buf);
for (var i = 0; i < buf.Length && result.Length < length; ++i)
{
// Divide the byte into allowedCharSet-sized groups. If the
// random value falls into the last group and the last group is
// too small to choose from the entire allowedCharSet, ignore
// the value in order to avoid biasing the result.
var outOfRangeStart = byteSize - (byteSize%allowedCharSet.Length);
if (outOfRangeStart <= buf[i]) continue;
result.Append(allowedCharSet[buf[i]%allowedCharSet.Length]);
}
}
return result.ToString();
}
}
private static void SaveAllConncectedComponents(Node<int> node,
HashSet<int> visitedNodes, List<string> connectedComponents)
{
string graphs = string.Empty;
Stack<Node<int>> nodesStack = new Stack<Node<int>>();
nodesStack.Push(node);
while (nodesStack.Count > 0)
{
Node<int> currentNode = nodesStack.Pop();
visitedNodes.Add(currentNode.Value);
graphs += " -> " + currentNode.Value;
foreach (var child in currentNode.Children)
{
if (!visitedNodes.Contains(child.Value))
{
visitedNodes.Add(child.Value);
nodesStack.Push(child);
}
}
}
connectedComponents.Add(graphs.Substring(4));
}
public static string GenerateText(TypeDeclaration type, OrderedPartCollection<AbstractDynamicCompilationExtension> extensions)
{
var unit = new CompilationUnit();
var namespaces = new HashSet<string>
{
typeof (SystemTime).Namespace,
typeof (AbstractViewGenerator).Namespace,
typeof (Enumerable).Namespace,
typeof (IEnumerable<>).Namespace,
typeof (IEnumerable).Namespace,
typeof (int).Namespace,
typeof (LinqOnDynamic).Namespace,
typeof(Field).Namespace,
};
foreach (var extension in extensions)
{
foreach (var ns in extension.Value.GetNamespacesToImport())
{
namespaces.Add(ns);
}
}
foreach (var ns in namespaces)
{
unit.AddChild(new Using(ns));
}
unit.AddChild(type);
var output = new CSharpOutputVisitor();
unit.AcceptVisitor(output, null);
return output.Text;
}
public User(StateManager stateMgr, API.Geo.World world)
{
this.mStateMgr = stateMgr;
this.mWorld = world;
this.mTimeSinceGUIOpen = new Timer();
this.mCameraMan = null;
this.IsAllowedToMoveCam = true;
this.IsFreeCamMode = true;
Camera cam = this.mStateMgr.Camera;
cam.Position = new Vector3(-203, 633, -183);
cam.Orientation = new Quaternion(0.3977548f, -0.1096644f, -0.8781486f, -0.2421133f);
this.mCameraMan = new CameraMan(cam);
this.mSelectedAllies = new HashSet<VanillaNonPlayer>();
this.mRandom = new Random();
this.mFigures = new MOIS.KeyCode[10];
for (int i = 0; i < 9; i++)
this.mFigures[i] = (MOIS.KeyCode)System.Enum.Parse(typeof(MOIS.KeyCode), "KC_" + (i + 1));
this.mFigures[9] = MOIS.KeyCode.KC_0;
this.mWireCube = this.mStateMgr.SceneMgr.RootSceneNode.CreateChildSceneNode();
this.mWireCube.AttachObject(StaticRectangle.CreateRectangle(this.mStateMgr.SceneMgr, Vector3.UNIT_SCALE * Cst.CUBE_SIDE));
this.mWireCube.SetVisible(false);
this.Inventory = new Inventory(10, 4, new int[] { 3, 0, 1, 2 }, true);
}
private bool m_useStrict; //= false;
#endregion Fields
#region Constructors
protected JsActivationObject(JsActivationObject parent, JsSettings codeSettings)
{
m_isKnownAtCompileTime = true;
m_useStrict = false;
m_settings = codeSettings;
Parent = parent;
NameTable = new Dictionary<string, JsVariableField>();
ChildScopes = new List<JsActivationObject>();
// if our parent is a scope....
if (parent != null)
{
// add us to the parent's list of child scopes
parent.ChildScopes.Add(this);
// if the parent is strict, so are we
UseStrict = parent.UseStrict;
}
// create the two lists of declared items for this scope
ScopeLookups = new HashSet<JsLookup>();
VarDeclaredNames = new HashSet<IJsNameDeclaration>();
LexicallyDeclaredNames = new HashSet<IJsNameDeclaration>();
GhostedCatchParameters = new HashSet<JsParameterDeclaration>();
GhostedFunctions = new HashSet<JsFunctionObject>();
}
/// <summary>
/// Add Hundreds of Stock and Forex Symbol
/// </summary>
public override void Initialize()
{
SetStartDate(2001, 10, 07);
SetEndDate(2010, 10, 11);
SetCash(250000);
var allSymbols = StressSymbols.StockSymbols.ToList();//.Concat(ForexSymbols).ToList();
if (TickSymbolsToRun + SecondSymbolsToRun + HourSymbolsToRun + DailySymbolsToRun > allSymbols.Count)
{
throw new Exception("Too many symbols, all symbols: " + allSymbols.Count);
}
var hash = new HashSet<string> {"DNY", "MLNK"};
var ticks = GetRandomSymbols(allSymbols, hash, TickSymbolsToRun).ToList();
var seconds = GetRandomSymbols(allSymbols, hash, SecondSymbolsToRun).ToList();
var minutes = GetRandomSymbols(allSymbols, hash, MinuteSymbolsToRun).ToList();
var hours = GetRandomSymbols(allSymbols, hash, HourSymbolsToRun).ToList();
var daily = GetRandomSymbols(allSymbols, hash, DailySymbolsToRun).ToList();
AddSecurity(ticks, Resolution.Tick);
AddSecurity(seconds, Resolution.Second);
AddSecurity(minutes, Resolution.Minute);
AddSecurity(hours, Resolution.Hour);
AddSecurity(daily, Resolution.Daily);
//SetUniverse(coarse => coarse.Take(1));
}
public Node(string name, FileAttributes attrs)
{
Attributes = attrs;
Name = name;
Parents = new HashSet<Node>();
Contains = new HashSet<Node>();
}
private static OrderedMultiDictionary<int, Article> GenerateArticles(int count)
{
var barcodes = new HashSet<string>();
Console.Write("Generating barcodes...");
while (barcodes.Count < count)
{
var barcode = RandomGenerator.GetRandomString(BarcodeLength);
barcodes.Add(barcode);
if (barcodes.Count % (count / 10) == 0)
{
Console.Write('.');
}
}
Console.Write("\n\nGenerating articles...");
var articles = new OrderedMultiDictionary<int, Article>(true);
foreach (var barcode in barcodes)
{
var vendor = RandomGenerator.GetRandomString(5);
var title = RandomGenerator.GetRandomString(7);
var price = RandomGenerator.GeneratRandomNumber(0, count);
var article = new Article(barcode, vendor, title, price);
articles.Add(price, article);
if (articles.Count % (count / 10) == 0)
{
Console.Write('.');
}
}
Console.WriteLine();
return articles;
}
// admin deletearea x y z radius
public override bool HandleCommand(ulong userId, string[] words)
{
HashSet<IMyEntity> entities = new HashSet<IMyEntity>();
HashSet<IMyEntity> entitiesToConfirm = new HashSet<IMyEntity>();
HashSet<IMyEntity> entitiesConnected = new HashSet<IMyEntity>();
HashSet<IMyEntity> entitiesFound = new HashSet<IMyEntity>();
Wrapper.GameAction(() =>
{
MyAPIGateway.Entities.GetEntities(entities, x => x is IMyCubeGrid);
});
foreach (IMyEntity entity in entities)
{
if (!(entity is IMyCubeGrid))
continue;
IMyCubeGrid grid = (IMyCubeGrid)entity;
MyObjectBuilder_CubeGrid gridBuilder = CubeGrids.SafeGetObjectBuilder(grid);
if (gridBuilder == null)
continue;
bool found = false;
foreach (MyObjectBuilder_CubeBlock block in gridBuilder.CubeBlocks)
{
if (block.TypeId == typeof(MyObjectBuilder_Beacon))
{
found = true;
break;
}
}
if (!found)
entitiesToConfirm.Add(grid);
}
CubeGrids.GetGridsUnconnected(entitiesFound, entitiesToConfirm);
foreach (IMyEntity entity in entitiesFound)
{
CubeGridEntity gridEntity = (CubeGridEntity)GameEntityManager.GetEntity(entity.EntityId);
if (gridEntity == null)
{
Log.Info("A found entity gridEntity was null!");
continue;
}
Communication.SendPrivateInformation(userId, string.Format("Found entity '{0}' ({1}) at {2} with no beacon.", gridEntity.Name, entity.EntityId, General.Vector3DToString(entity.GetPosition())));
}
for(int r = entitiesFound.Count - 1; r >= 0; r--)
{
//MyAPIGateway.Entities.RemoveEntity(entity);
IMyEntity entity = entitiesFound.ElementAt(r);
CubeGridEntity gridEntity = new CubeGridEntity((MyObjectBuilder_CubeGrid)entity.GetObjectBuilder(), entity);
gridEntity.Dispose();
}
Communication.SendPrivateInformation(userId, string.Format("Removed {0} grids with no beacons", entitiesFound.Count));
return true;
}
public static IEnumerable<string> GetAllStyleSheets(string searchFrom, IEnumerable<string> allowedExtensions)
{
var project = ProjectHelpers.GetProject(searchFrom);
var projectPath = project.Properties.Item("FullPath").Value.ToString();
var projectUri = new Uri(projectPath, UriKind.Absolute);
var fileNames = new HashSet<string>();
var projectDir = Path.GetDirectoryName(projectPath);
if (projectDir == null)
{
return new string[0];
}
foreach (var extension in allowedExtensions)
{
var matchingFiles = Directory.GetFiles(projectDir, "*" + extension, SearchOption.AllDirectories);
foreach (var file in matchingFiles)
{
var mappedFile = GetStyleSheetFileForUrl(file, project, projectUri);
if (mappedFile != null)
{
fileNames.Add(mappedFile);
}
}
}
return fileNames;
}
public Project() {
Configuration = new ClientConfiguration();
NotificationSettings = new Dictionary<string, NotificationSettings>();
PromotedTabs = new HashSet<string>();
DeleteBotDataEnabled = true;
Data = new DataDictionary();
}
public static VTable ConstructVTable(TypeDef typeDef, VTableStorage storage)
{
var ret = new VTable(typeDef);
var slotDict = new Dictionary<VTableSignature, List<VTableSlot>>();
// Partition II 12.2
// Interfaces
foreach (InterfaceImpl iface in typeDef.Interfaces) {
VTable ifaceVTbl = storage.GetVTable(iface.Interface);
if (ifaceVTbl != null)
ret.Inherit(ifaceVTbl, slotDict);
}
// Base type
VTable baseVTbl = storage.GetVTable(typeDef.GetBaseTypeThrow());
if (baseVTbl != null)
ret.Inherit(baseVTbl, slotDict);
List<MethodDef> virtualMethods = typeDef.Methods.Where(method => method.IsVirtual).ToList();
var methodsProcessed = new HashSet<MethodDef>();
// MethodImpls (Partition II 22.27)
foreach (MethodDef method in virtualMethods)
foreach (MethodOverride impl in method.Overrides) {
Debug.Assert(impl.MethodBody == method);
MethodDef targetMethod = impl.MethodDeclaration.ResolveThrow();
VTableSignature sig = VTableSignature.FromMethod(impl.MethodDeclaration);
Debug.Assert(slotDict.ContainsKey(sig));
var methodSlot = new VTableSlot(ret, method, method.DeclaringType.ToTypeSig(), VTableSignature.FromMethod(method));
ret.Override(slotDict, sig, methodSlot, targetMethod);
methodsProcessed.Add(method);
}
// Normal override
foreach (MethodDef method in virtualMethods) {
VTableSignature sig = VTableSignature.FromMethod(method);
var methodSlot = new VTableSlot(ret, method, method.DeclaringType.ToTypeSig(), sig);
if (slotDict.ContainsKey(sig) && slotDict[sig].Count > 0) {
ret.Override(slotDict, sig, methodSlot);
methodsProcessed.Add(method);
}
}
// Remaining methods
foreach (MethodDef method in typeDef.Methods.Where(method => method.IsVirtual).Except(methodsProcessed)) {
var slot = new VTableSlot(ret, method, method.DeclaringType.ToTypeSig(), VTableSignature.FromMethod(method));
if (method.IsFinal)
ret.Finals.Add(slot);
else {
Debug.Assert(!ret.Slots.Any(s => s.MethodDef == method));
ret.Slots.Add(slot);
}
}
return ret;
}