private void Awake() { mobileInput = FindObjectOfType <MobileInput>(); ballsController = FindObjectOfType <BallsController>(); blockContainer = FindObjectOfType <BlockContainer>(); ballsPreview.gameObject.SetActive(false); }
private void MoveBlocksIntoContainer(List <ControlFlowNode> loop, BlockContainer loopContainer) { // Move other blocks into the loop body: they're all dominated by the loop header, // and thus cannot be the target of branch instructions outside the loop. for (int i = 1; i < loop.Count; i++) { Block block = (Block)loop[i].UserData; // some blocks might already be in use by nested loops that were detected earlier; // don't move those (they'll be implicitly moved when the block containing the // nested loop container is moved). if (block.Parent == currentBlockContainer) { Debug.Assert(block.ChildIndex != 0); int oldChildIndex = block.ChildIndex; loopContainer.Blocks.Add(block); currentBlockContainer.Blocks.SwapRemoveAt(oldChildIndex); } } for (int i = 1; i < loop.Count; i++) { // Verify that we moved all loop blocks into the loop container. // If we wanted to move any blocks already in use by a nested loop, // this means we check that the whole nested loop got moved. Block block = (Block)loop[i].UserData; Debug.Assert(block.IsDescendantOf(loopContainer)); } }
/// <summary> /// Ensures that every write to a pinned local is followed by a branch instruction. /// This ensures the 'pinning region' does not involve any half blocks, which makes it easier to extract. /// </summary> void SplitBlocksAtWritesToPinnedLocals(BlockContainer container) { for (int i = 0; i < container.Blocks.Count; i++) { var block = container.Blocks[i]; for (int j = 0; j < block.Instructions.Count - 1; j++) { var inst = block.Instructions[j]; ILVariable v; if (inst.MatchStLoc(out v) && v.Kind == VariableKind.PinnedLocal && block.Instructions[j + 1].OpCode != OpCode.Branch) { // split block after j: context.Step("Split block after pinned local write", inst); var newBlock = new Block(); for (int k = j + 1; k < block.Instructions.Count; k++) { newBlock.Instructions.Add(block.Instructions[k]); } newBlock.AddILRange(newBlock.Instructions[0]); block.Instructions.RemoveRange(j + 1, newBlock.Instructions.Count); block.Instructions.Add(new Branch(newBlock)); container.Blocks.Insert(i + 1, newBlock); } } } }
public virtual void ButtonDown(Block listener, Block button) { if (button.IsA(Block.Type.REDBUTTON)) { Game g = Game.Instance; GameLevel gl = g.Level; BlockContainer bc = gl.GetBlockContainer(listener); // Take the first creature and clone it Block b = bc.Upper; if (b.Creature || b.IsBlock()) { BlockContainer moveTo = gl.GetBlockContainer(b, b.Facing); if (moveTo.CanMoveTo(b)) { try { Block clone = g.BlockFactory.Get(b.getType(), b.Facing); Point p = b.Point; // Move.updatePoint(p, b.getFacing()); if (clone.Creature && !(clone.IsA(Block.Type.TEETH) || clone.IsA(Block.Type.BLOB) || clone.IsA(Block.Type.FIREBALL))) { g.AddBlockDelay(clone, p, 3); } else { gl.AddBlock(p.X, p.Y, clone, 2); gl.MoveBlock(clone, clone.Facing, true, false); if (clone.Creature) { Creatures.AddCreature(clone); } } } catch (BlockContainerFullException) { // Ignore for now. TODO: Fix } } } try { b.Clone(); if (b.Creature) { Creatures.Boss = b; } } catch (Exception) { // System.out.println("Couldn't clone " + b); // Ignore } } }
static bool CombineBlockWithNextBlock(BlockContainer container, Block block, ILTransformContext context) { Debug.Assert(container == block.Parent); // Ensure the block will stay a basic block -- we don't want extended basic blocks prior to LoopDetection. if (block.Instructions.Count > 1 && block.Instructions[block.Instructions.Count - 2].HasFlag(InstructionFlags.MayBranch)) { return(false); } Branch br = block.Instructions.Last() as Branch; // Check whether we can combine the target block with this block if (br == null || br.TargetBlock.Parent != container || br.TargetBlock.IncomingEdgeCount != 1) { return(false); } if (br.TargetBlock == block) { return(false); // don't inline block into itself } context.Step("CombineBlockWithNextBlock", br); var targetBlock = br.TargetBlock; if (targetBlock.ILRange.Start < block.ILRange.Start && IsDeadTrueStore(block)) { // The C# compiler generates a dead store for the condition of while (true) loops. block.Instructions.RemoveRange(block.Instructions.Count - 3, 2); } block.Instructions.Remove(br); block.Instructions.AddRange(targetBlock.Instructions); targetBlock.Instructions.Clear(); // mark targetBlock for deletion return(true); }
/// <summary> /// Builds structured control flow for the block associated with the control flow node. /// </summary> /// <remarks> /// After a block was processed, it should use structured control flow /// and have just a single 'regular' exit point (last branch instruction in the block) /// </remarks> public void Run(Block block, BlockTransformContext context) { this.context = context; currentContainer = (BlockContainer)block.Parent; // We only embed blocks into this block if they aren't referenced anywhere else, // so those blocks are dominated by this block. // BlockILTransform thus guarantees that the blocks being embedded are already // fully processed. cfgNode = context.ControlFlowNode; Debug.Assert(cfgNode.UserData == block); // Because this transform runs at the beginning of the block transforms, // we know that `block` is still a (non-extended) basic block. // Previous-to-last instruction might have conditional control flow, // usually an IfInstruction with a branch: if (block.Instructions.SecondToLastOrDefault() is IfInstruction ifInst) { HandleIfInstruction(block, ifInst); } else { InlineExitBranch(block); } }
/// <summary> /// Unwraps a nested BlockContainer, if container contains only a single block, /// and that single block contains only a BlockContainer followed by a Leave instruction. /// If the leave instruction is a return that carries a value, the container is unwrapped only /// if the value has no side-effects. /// Otherwise returns the unmodified container. /// </summary> /// <param name="optionalReturnInst">If the leave is a return and has no side-effects, we can move the return out of the using-block and put it after the loop, otherwise returns null.</param> BlockContainer UnwrapNestedContainerIfPossible(BlockContainer container, out Leave optionalReturnInst) { optionalReturnInst = null; // Check block structure: if (container.Blocks.Count != 1) { return(container); } var nestedBlock = container.Blocks[0]; if (nestedBlock.Instructions.Count != 2 || !(nestedBlock.Instructions[0] is BlockContainer nestedContainer) || !(nestedBlock.Instructions[1] is Leave leave)) { return(container); } // If the leave has no value, just unwrap the BlockContainer. if (leave.MatchLeave(container)) { return(nestedContainer); } // If the leave is a return, we can move the return out of the using-block and put it after the loop // (but only if the value doesn't have side-effects) if (leave.IsLeavingFunction && SemanticHelper.IsPure(leave.Value.Flags)) { optionalReturnInst = leave; return(nestedContainer); } return(container); }
protected internal override Statement VisitBlockContainer(BlockContainer container) { if (container.EntryPoint.IncomingEdgeCount > 1) { var oldContinueTarget = continueTarget; var oldContinueCount = continueCount; var oldBreakTarget = breakTarget; var loop = ConvertLoop(container); loop.AddAnnotation(container); continueTarget = oldContinueTarget; continueCount = oldContinueCount; breakTarget = oldBreakTarget; return(loop); } else if (container.EntryPoint.Instructions.Count == 1 && container.EntryPoint.Instructions[0] is SwitchInstruction switchInst) { return(TranslateSwitch(container, switchInst)); } else { var blockStmt = ConvertBlockContainer(container, false); blockStmt.AddAnnotation(container); return(blockStmt); } }
protected bool IsKnownStaticBlock(BlockContainer block) { // If the block was written to less than 3 minutes ago, return false if (block.LastWrite > DateTime.Now.AddMinutes(-(3 * 60 * 1000))) { return(false); } // Extract the server key from the block id BlockId blockId = block.Id; int serverId = ((int)blockId.Low & 0x0FF); // Look up the max known block id for the manager server, BlockId maxBlockId; lock (maxKnownBlockId) { maxKnownBlockId.TryGetValue(serverId, out maxBlockId); } // If the block is less than the max, the block can be compressed! if (maxBlockId != null && blockId.CompareTo(maxBlockId) < 0) { return(true); } // Otherwise update the last write flag (so we only check the max block id // every 3 mins). block.TouchLastWrite(); return(false); }
internal static bool IsCatchWhenBlock(Block block) { var container = BlockContainer.FindClosestContainer(block); return(container?.Parent is TryCatchHandler handler && handler.Filter == container); }
public TransformDisplayClassUsages(IInstructionWithVariableOperand targetLoad, BlockContainer captureScope, List <ILInstruction> orphanedVariableInits) { this.targetLoad = targetLoad; this.captureScope = captureScope; this.orphanedVariableInits = orphanedVariableInits; this.targetAndCopies.Add(targetLoad.Variable); }
public void Run(ILFunction function, ILTransformContext context) { this.context = context; foreach (var container in function.Descendants.OfType <BlockContainer>()) { currentContainer = container; controlFlowGraph = null; bool blockContainerNeedsCleanup = false; foreach (var block in container.Blocks) { context.CancellationToken.ThrowIfCancellationRequested(); ProcessBlock(block, ref blockContainerNeedsCleanup); } if (blockContainerNeedsCleanup) { Debug.Assert(container.Blocks.All(b => b.Instructions.Count != 0 || b.IncomingEdgeCount == 0)); // if the original code has an unreachable switch-like condition // eg. if (i >= 0) { ... } else if (i == 2) { unreachable } // then the 'i == 2' block head gets consumed and the unreachable code needs deleting if (context.Settings.RemoveDeadCode) { container.SortBlocks(deleteUnreachableBlocks: true); } else { container.Blocks.RemoveAll(b => b.Instructions.Count == 0); } } } }
BlockContainer UnwrapNestedContainerIfPossible(BlockContainer container, out Leave optionalReturnInst) { optionalReturnInst = null; if (container.Blocks.Count != 1) { return(container); } var nestedBlock = container.Blocks[0]; if (nestedBlock.Instructions.Count != 2 || !(nestedBlock.Instructions[0] is BlockContainer nestedContainer) || !(nestedBlock.Instructions[1] is Leave leave)) { return(container); } if (leave.MatchLeave(container)) { return(nestedContainer); } if (leave.IsLeavingFunction) { optionalReturnInst = leave; return(nestedContainer); } return(container); }
void Awake() { _meshRenderer = GetComponent <MeshRenderer>(); _meshFilter = GetComponent <MeshFilter>(); _blockContainer = GetComponent <BlockContainer>(); _mesh = new Mesh(); }
private long BlockChecksum(Dictionary <BlockId, BlockContainer> containersTouched, BlockId blockId) { // Fetch the block container, BlockContainer container = GetBlock(containersTouched, blockId); // Calculate the checksum value, return(container.CreateChecksum()); }
protected internal override void VisitBlockContainer(BlockContainer container) { var oldExit = currentExit; var oldContainer = currentContainer; var oldPotentialExits = potentialExits; var thisExit = GetExit(container); currentExit = thisExit; currentContainer = container; potentialExits = (thisExit == ExitNotYetDetermined ? new List <ILInstruction>() : null); base.VisitBlockContainer(container); if (thisExit == ExitNotYetDetermined && potentialExits.Count > 0) { // This transform determined an exit point. currentExit = ChooseExit(potentialExits); foreach (var exit in potentialExits) { if (CompatibleExitInstruction(currentExit, exit)) { exit.ReplaceWith(new Leave(currentContainer) { ILRange = exit.ILRange }); } } Debug.Assert(!currentExit.MatchLeave(currentContainer)); ILInstruction inst = container; // traverse up to the block (we'll always find one because GetExit // only returns ExitNotYetDetermined if there's a block) while (inst.Parent.OpCode != OpCode.Block) { inst = inst.Parent; } Block block = (Block)inst.Parent; if (block.HasFlag(InstructionFlags.EndPointUnreachable)) { // Special case: despite replacing the exits with leave(currentContainer), // we still have an unreachable endpoint. // The appended currentExit instruction would not be reachable! // This happens in test case ExceptionHandling.ThrowInFinally() if (currentExit is Branch b) { blocksPotentiallyMadeUnreachable.Add(b.TargetBlock); } } else { block.Instructions.Add(currentExit); } } else { Debug.Assert(thisExit == currentExit); } currentExit = oldExit; currentContainer = oldContainer; potentialExits = oldPotentialExits; }
/// <summary> /// Block falseBlock (incoming: 1) { /// stloc returnVar(ldc.i4 0) /// br exitBlock /// } /// </summary> bool MatchFalseBlock(BlockContainer container, Block falseBlock, out ILVariable returnVar, out Block exitBlock) { returnVar = null; exitBlock = null; if (falseBlock.IncomingEdgeCount != 1 || falseBlock.Instructions.Count != 2) { return(false); } return(falseBlock.Instructions[0].MatchStLoc(out returnVar, out var zero) &&
void IILTransform.Run(ILFunction function, ILTransformContext context) { if (!context.Settings.AnonymousMethods) { return; } this.context = context; this.decompilationContext = new SimpleTypeResolveContext(function.Method); var orphanedVariableInits = new List <ILInstruction>(); var targetsToReplace = new List <IInstructionWithVariableOperand>(); var translatedDisplayClasses = new HashSet <ITypeDefinition>(); var cancellationToken = context.CancellationToken; foreach (var inst in function.Descendants) { cancellationToken.ThrowIfCancellationRequested(); if (inst is NewObj call) { context.StepStartGroup($"TransformDelegateConstruction {call.StartILOffset}", call); ILFunction f = TransformDelegateConstruction(call, out ILInstruction target); if (f != null && target is IInstructionWithVariableOperand instWithVar) { if (instWithVar.Variable.Kind == VariableKind.Local) { instWithVar.Variable.Kind = VariableKind.DisplayClassLocal; } targetsToReplace.Add(instWithVar); } context.StepEndGroup(); } if (inst.MatchStLoc(out ILVariable targetVariable, out ILInstruction value)) { var newObj = value as NewObj; // TODO : it is probably not a good idea to remove *all* display-classes // is there a way to minimize the false-positives? if (newObj != null && IsInSimpleDisplayClass(newObj.Method)) { targetVariable.CaptureScope = BlockContainer.FindClosestContainer(inst); targetsToReplace.Add((IInstructionWithVariableOperand)inst); translatedDisplayClasses.Add(newObj.Method.DeclaringTypeDefinition); } } } foreach (var target in targetsToReplace.OrderByDescending(t => ((ILInstruction)t).StartILOffset)) { context.Step($"TransformDisplayClassUsages {target.Variable}", (ILInstruction)target); function.AcceptVisitor(new TransformDisplayClassUsages(function, target, target.Variable.CaptureScope, orphanedVariableInits, translatedDisplayClasses)); } context.Step($"Remove orphanedVariableInits", function); foreach (var store in orphanedVariableInits) { if (store.Parent is Block containingBlock) { containingBlock.Instructions.Remove(store); } } }
public TransformDisplayClassUsages(ILFunction function, IInstructionWithVariableOperand targetLoad, BlockContainer captureScope, List <ILInstruction> orphanedVariableInits, HashSet <ITypeDefinition> translatedDisplayClasses) { this.currentFunction = function; this.targetLoad = targetLoad; this.captureScope = captureScope; this.orphanedVariableInits = orphanedVariableInits; this.translatedDisplayClasses = translatedDisplayClasses; this.targetAndCopies.Add(targetLoad.Variable); }
private void UpdateBlockState(BlockId blockId) { // Update internal state as appropriate, lock (pathLock) { BlockContainer container = LoadBlock(blockId); blockContainerMap[blockId] = container; ++blockCount; } }
/// <summary> /// Ensures that every write to a pinned local is followed by a branch instruction. /// This ensures the 'pinning region' does not involve any half blocks, which makes it easier to extract. /// </summary> void SplitBlocksAtWritesToPinnedLocals(BlockContainer container) { for (int i = 0; i < container.Blocks.Count; i++) { var block = container.Blocks[i]; for (int j = 0; j < block.Instructions.Count - 1; j++) { var inst = block.Instructions[j]; if (inst.MatchStLoc(out ILVariable v, out var value) && v.Kind == VariableKind.PinnedLocal) { if (block.Instructions[j + 1].OpCode != OpCode.Branch) { // split block after j: context.Step("Split block after pinned local write", inst); var newBlock = new Block(); for (int k = j + 1; k < block.Instructions.Count; k++) { newBlock.Instructions.Add(block.Instructions[k]); } newBlock.AddILRange(newBlock.Instructions[0]); block.Instructions.RemoveRange(j + 1, newBlock.Instructions.Count); block.Instructions.Add(new Branch(newBlock)); container.Blocks.Insert(i + 1, newBlock); } // in case of re-pinning (e.g. C++/CLI assignment to pin_ptr variable), // it's possible for the new value to be dependent on the old. if (v.IsUsedWithin(value)) { // In this case, we need to un-inline the uses of the pinned local // so that they are split off into the block prior to the pinned local write var temp = context.Function.RegisterVariable(VariableKind.StackSlot, v.Type); block.Instructions.Insert(j++, new StLoc(temp, new LdLoc(v))); foreach (var descendant in value.Descendants) { if (descendant.MatchLdLoc(v)) { descendant.ReplaceWith(new LdLoc(temp).WithILRange(descendant)); } } } if (j > 0) { // split block before j: context.Step("Split block before pinned local write", inst); var newBlock = new Block(); newBlock.Instructions.Add(block.Instructions[j]); newBlock.Instructions.Add(block.Instructions[j + 1]); newBlock.AddILRange(newBlock.Instructions[0]); Debug.Assert(block.Instructions.Count == j + 2); block.Instructions.RemoveRange(j, 2); block.Instructions.Insert(j, new Branch(newBlock)); container.Blocks.Insert(i + 1, newBlock); } } } } }
public static void Main(string[] args) { BlockContainer container = GetBlockContainer(2, 0); //The Block with only 24f values. Block result = Apply3x3Filter(Filter, container); Console.WriteLine(string.Join(Environment.NewLine, result.TextLines)); Console.WriteLine("Press enter to exit..."); Console.ReadLine(); }
protected internal override void VisitBlockContainer(BlockContainer container) { if (container.Kind == ContainerKind.Switch) { // Special case for switch: Only visit the switch condition block. var switchInst = (SwitchInstruction)container.EntryPoint.Instructions[0]; switchInst.Value.AcceptVisitor(this); } // No need to call base.VisitBlockContainer, see comment in VisitBlock. }
private void DetermineCaptureAndDeclarationScopes(Dictionary <MethodDefinitionHandle, LocalFunctionInfo> .ValueCollection localFunctions) { foreach (var info in localFunctions) { context.CancellationToken.ThrowIfCancellationRequested(); if (info.Definition == null) { context.Function.Warnings.Add($"Could not decode local function '{info.Method}'"); continue; } context.StepStartGroup($"Determine and move to declaration scope of " + info.Definition.Name, info.Definition); try { var localFunction = info.Definition; foreach (var useSite in info.UseSites) { DetermineCaptureAndDeclarationScope(info, useSite); if (context.Function.Method.IsConstructor && localFunction.DeclarationScope == null) { localFunction.DeclarationScope = BlockContainer.FindClosestContainer(useSite); } } if (localFunction.DeclarationScope == null) { localFunction.DeclarationScope = (BlockContainer)context.Function.Body; } ILFunction declaringFunction = GetDeclaringFunction(localFunction); if (declaringFunction != context.Function) { context.Step($"Move {localFunction.Name} from {context.Function.Name} to {declaringFunction.Name}", localFunction); context.Function.LocalFunctions.Remove(localFunction); declaringFunction.LocalFunctions.Add(localFunction); } if (TryValidateSkipCount(info, out int skipCount) && skipCount != localFunction.ReducedMethod.NumberOfCompilerGeneratedTypeParameters) { Debug.Assert(false); context.Function.Warnings.Add($"Could not decode local function '{info.Method}'"); if (declaringFunction != context.Function) { declaringFunction.LocalFunctions.Remove(localFunction); } } } finally { context.StepEndGroup(keepIfEmpty: true); } } }
public static SelectedStatementsInfo Create(BlockSyntax block, TextSpan span) { if (block == null) { throw new ArgumentNullException(nameof(block)); } var container = new BlockContainer(block); return(new SelectedStatementsInfo(container, span)); }
private void ScheduleFileFlush(BlockContainer container, int delay) { lock (pathLock) { if (!blocksPendingSync.Contains(container)) { blocksPendingSync.AddFirst(container); new Timer(FileFlushTask, container, delay, Timeout.Infinite); } } }
private BlockContainer LoadBlock(BlockId blockId) { IBlockStore blockStore = GetBlockStore(blockId); // Make the block container object, BlockContainer container = new BlockContainer(blockId, blockStore); OnBlockLoaded(container); return(container); }
static bool UsesVariableCapturedInLoop(BlockContainer loop, ILInstruction condition) { foreach (var inst in condition.Descendants.OfType <IInstructionWithVariableOperand>()) { if (inst.Variable.CaptureScope == loop) { return(true); } } return(false); }
BlockStatement ConvertBlockContainer(BlockStatement blockStatement, BlockContainer container, IEnumerable <Block> blocks, bool isLoop) { foreach (var block in blocks) { if (block.IncomingEdgeCount > 1 || block != container.EntryPoint) { // If there are any incoming branches to this block, add a label: blockStatement.Add(new LabelStatement { Label = block.Label }); } foreach (var inst in block.Instructions) { if (!isLoop && inst.OpCode == OpCode.Leave && IsFinalLeave((Leave)inst)) { // skip the final 'leave' instruction and just fall out of the BlockStatement continue; } var stmt = Convert(inst); if (stmt is BlockStatement b) { foreach (var nested in b.Statements) { blockStatement.Add(nested.Detach()); } } else { blockStatement.Add(stmt); } } if (block.FinalInstruction.OpCode != OpCode.Nop) { blockStatement.Add(Convert(block.FinalInstruction)); } } string label; if (endContainerLabels.TryGetValue(container, out label)) { if (isLoop) { blockStatement.Add(new ContinueStatement()); } blockStatement.Add(new LabelStatement { Label = label }); if (isLoop) { blockStatement.Add(new BreakStatement()); } } return(blockStatement); }
static bool MatchDoWhileConditionBlock(BlockContainer loop, Block block, out bool swapBranches) { // match the end of the block: // if (condition) branch entry-point else nop // leave loop // -or- // if (condition) leave loop else nop // branch entry-point swapBranches = false; // empty block? if (block.Instructions.Count < 2) { return(false); } var last = block.Instructions.Last(); var ifInstruction = block.Instructions.SecondToLastOrDefault() as IfInstruction; // no IfInstruction or already transformed? if (ifInstruction == null || !ifInstruction.FalseInst.MatchNop()) { return(false); } // if the last instruction is a branch // we assume the branch instructions need to be swapped. if (last.MatchBranch(loop.EntryPoint)) { swapBranches = true; } else if (last.MatchLeave(loop)) { swapBranches = false; } else { return(false); } // match the IfInstruction if (swapBranches) { if (!ifInstruction.TrueInst.MatchLeave(loop)) { return(false); } } else { if (!ifInstruction.TrueInst.MatchBranch(loop.EntryPoint)) { return(false); } } return(true); }
public CompositeTitle(BlockContainer container) { CompositeTitle compositeTitle = this; if (container == null) { string str = "Null 'container' argument."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { this.container = container; this.backgroundPaint = (Paint) null; } }
private void button1_Click(object sender, EventArgs e) { var applicationContainer = new BlockContainer(); BlockRegister.Initialize(applicationContainer); var cachingBlock = new CachingBlock(); BlockRegister.RegisterInstance<CachingBlock>(cachingBlock); var mBackingStore = new NullBackingStore(); var mInstrumentationProvider = new NullCachingInstrumentationProvider(); var dataCache = new Cache(mBackingStore, mInstrumentationProvider); var mExpirationTask = new ExpirationTask(dataCache, mInstrumentationProvider); var mScavengerTask = new ScavengerTask(1, 5, dataCache, mInstrumentationProvider); var mBackgroundScheduler = new BackgroundScheduler(mExpirationTask, mScavengerTask, mInstrumentationProvider); var mExpirationPollTimer = new ExpirationPollTimer(1000); var dataCacheManager = new CacheManager(dataCache, mBackgroundScheduler, mExpirationPollTimer); var mCachingBlock = BlockRegister.GetInstance<CachingBlock>(); mCachingBlock.RegisterInstance("MyApplicationCache", dataCacheManager); }
protected override BlockContainer LoadBlock(long blockId) { // If it's not found in the map, // Turn the block id into a filename, String block_fname = blockId.ToString(); string block_file_name = Path.Combine(path, block_fname + ".mcd"); IBlockStore block_store; if (!File.Exists(block_file_name)) { block_file_name = Path.Combine(path, block_fname); // If this file doesn't exist, if (!File.Exists(block_file_name)) { // We check if the block_id is less than maximum id. If it is we // generate an exception indicating this block doesn't exist on this // service. This means something screwed up, either the manager service // was erroneously told the block was located on this service but it // isn't, or the file was deleted by the user. if (blockId < LastBlockId) throw new BlockReadException("Block " + blockId + " not stored on service"); } block_store = new FileBlockStore(blockId, block_file_name); } else { block_store = new CompressedBlockStore(blockId, block_file_name); } // Make the block container object, BlockContainer container = new BlockContainer(blockId, block_store); // Add the new container to the control list (used by the compression // thread). lock (compressionAddList) { compressionAddList.Add(container); } return container; }
public LegendTitle(LegendItemSource source, Arrangement hLayout, Arrangement vLayout) { LegendTitle legendTitle = this; LegendItemSource[] legendItemSourceArray = new LegendItemSource[1]; int index = 0; LegendItemSource legendItemSource = source; legendItemSourceArray[index] = legendItemSource; this.sources = legendItemSourceArray; this.items = new BlockContainer(hLayout); this.hLayout = hLayout; this.vLayout = vLayout; this.backgroundPaint = (Paint) null; this.legendItemGraphicEdge = RectangleEdge.__\u003C\u003ELEFT; this.legendItemGraphicAnchor = RectangleAnchor.__\u003C\u003ECENTER; this.legendItemGraphicLocation = RectangleAnchor.__\u003C\u003ECENTER; this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0); this.itemFont = LegendTitle.__\u003C\u003EDEFAULT_ITEM_FONT; this.itemPaint = LegendTitle.__\u003C\u003EDEFAULT_ITEM_PAINT; this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0); }
public void OnMouseDown() { isSelected = true; if(OnBeginDragAction != null) OnBeginDragAction(this); oldPosition = transform.position; oldParentContainer = ParenContainer; }
private void button3_Click(object sender, EventArgs e) { var applicationContainer = new BlockContainer(); BlockRegister.Initialize(applicationContainer); var cachingBlock = new CachingBlock(); var dataCacheManager = new CacheManager(); BlockRegister.RegisterInstance<CachingBlock>(cachingBlock); cachingBlock.RegisterInstance("MyApplicationCache", dataCacheManager); }